From a0647a89a82e892292c421f5c968de2f28d42366 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 24 Oct 2005 07:11:40 +0000 Subject: r11272: In trying to track down why Win2k3 is again rejecting our PAC, ensure we can round-trip all the way back to a server_info structure, not just a filled in PAC_DATA. (I was worried about generated fields being incorrect, or some other logical flaw). Andrew Bartlett (This used to be commit 11b1d78cc550c60201d12f8778ca8533712a5b1e) --- source4/auth/auth_sam_reply.c | 120 +++++++++++------------------------------- 1 file changed, 32 insertions(+), 88 deletions(-) (limited to 'source4/auth/auth_sam_reply.c') diff --git a/source4/auth/auth_sam_reply.c b/source4/auth/auth_sam_reply.c index 85a54979ce..2918dfd499 100644 --- a/source4/auth/auth_sam_reply.c +++ b/source4/auth/auth_sam_reply.c @@ -36,6 +36,10 @@ NTSTATUS auth_convert_server_info_sambaseinfo(TALLOC_CTX *mem_ctx, struct netr_SamBaseInfo *sam = talloc_zero(mem_ctx, struct netr_SamBaseInfo); NT_STATUS_HAVE_NO_MEMORY(sam); + sam->domain_sid = dom_sid_dup(mem_ctx, server_info->account_sid); + NT_STATUS_HAVE_NO_MEMORY(sam->domain_sid); + sam->domain_sid->num_auths--; + sam->last_logon = server_info->last_logon; sam->last_logoff = server_info->last_logoff; sam->acct_expiry = server_info->acct_expiry; @@ -67,8 +71,11 @@ NTSTATUS auth_convert_server_info_sambaseinfo(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; for (i=0; in_domain_groups; i++) { - struct dom_sid *group_sid = server_info->domain_groups[i]; + if (!dom_sid_in_domain(sam->domain_sid, group_sid)) { + /* We handle this elsewhere */ + continue; + } sam->groups.rids[sam->groups.count].rid = group_sid->sub_auths[group_sid->num_auths-1]; @@ -82,13 +89,9 @@ NTSTATUS auth_convert_server_info_sambaseinfo(TALLOC_CTX *mem_ctx, * as extra sids (PAC doc) but what is * 0x100? */ sam->acct_flags = server_info->acct_flags; - sam->logon_server.string = lp_netbios_name(); + sam->logon_server.string = server_info->logon_server; sam->domain.string = server_info->domain_name; - sam->domain_sid = dom_sid_dup(mem_ctx, server_info->account_sid); - NT_STATUS_HAVE_NO_MEMORY(sam->domain_sid); - sam->domain_sid->num_auths--; - ZERO_STRUCT(sam->unknown); ZERO_STRUCT(sam->key); @@ -113,96 +116,37 @@ NTSTATUS auth_convert_server_info_saminfo3(TALLOC_CTX *mem_ctx, { struct netr_SamBaseInfo *sam; struct netr_SamInfo3 *sam3 = talloc_zero(mem_ctx, struct netr_SamInfo3); + NTSTATUS status; + int i; NT_STATUS_HAVE_NO_MEMORY(sam3); - sam = &sam3->base; - - sam->domain_sid = dom_sid_dup(mem_ctx, server_info->account_sid); - NT_STATUS_HAVE_NO_MEMORY(sam->domain_sid); - sam->domain_sid->num_auths--; - - sam->last_logon = server_info->last_logon; - sam->last_logoff = server_info->last_logoff; - sam->acct_expiry = server_info->acct_expiry; - sam->last_password_change = server_info->last_password_change; - sam->allow_password_change = server_info->allow_password_change; - sam->force_password_change = server_info->force_password_change; - - sam->account_name.string = server_info->account_name; - sam->full_name.string = server_info->full_name; - sam->logon_script.string = server_info->logon_script; - sam->profile_path.string = server_info->profile_path; - sam->home_directory.string = server_info->home_directory; - sam->home_drive.string = server_info->home_drive; - - sam->logon_count = server_info->logon_count; - sam->bad_password_count = sam->bad_password_count; - sam->rid = server_info->account_sid->sub_auths[server_info->account_sid->num_auths-1]; - sam->primary_gid = server_info->primary_group_sid->sub_auths[server_info->primary_group_sid->num_auths-1]; - - sam->groups.count = 0; - sam->groups.rids = NULL; - - if (server_info->n_domain_groups > 0) { - int i; - sam->groups.rids = talloc_array(sam, struct samr_RidWithAttribute, - server_info->n_domain_groups); - NT_STATUS_HAVE_NO_MEMORY(sam->groups.rids); - - for (i=0; in_domain_groups; i++) { - struct dom_sid *group_sid = server_info->domain_groups[i]; - - if (!dom_sid_in_domain(sam->domain_sid, group_sid)) { - continue; - } - - sam->groups.rids[sam->groups.count].rid = group_sid->sub_auths[group_sid->num_auths-1]; - sam->groups.rids[sam->groups.count].attributes = - SE_GROUP_MANDATORY | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_ENABLED; - sam->groups.count += 1; - } + status = auth_convert_server_info_sambaseinfo(mem_ctx, server_info, &sam); + if (!NT_STATUS_IS_OK(status)) { + return status; } - - sam->user_flags = 0x20; /* TODO: w2k3 uses 0x120. We know 0x20 - * as extra sids (PAC doc) but what is - * 0x100? */ - sam->acct_flags = server_info->acct_flags; - sam->logon_server.string = lp_netbios_name(); - sam->domain.string = server_info->domain_name; - - ZERO_STRUCT(sam->unknown); - - ZERO_STRUCT(sam->key); - if (server_info->user_session_key.length == sizeof(sam->key.key)) { - memcpy(sam->key.key, server_info->user_session_key.data, sizeof(sam->key.key)); - } - - ZERO_STRUCT(sam->LMSessKey); - if (server_info->lm_session_key.length == sizeof(sam->LMSessKey.key)) { - memcpy(sam->LMSessKey.key, server_info->lm_session_key.data, - sizeof(sam->LMSessKey.key)); - } - + sam3->base = *sam; sam3->sidcount = 0; sam3->sids = NULL; -#if 0 - if (server_info->n_domain_groups > 0) { - int i; - sam3->sids = talloc_array(sam, struct netr_SidAttr, - server_info->n_domain_groups); - NT_STATUS_HAVE_NO_MEMORY(sam3->sids); - for (i=0; in_domain_groups; i++) { - if (dom_sid_in_domain(sam->domain_sid, server_info->domain_groups[i])) { - continue; - } - sam3->sids[sam3->sidcount].sid = talloc_reference(sam3->sids,server_info->domain_groups[i]); - sam3->sids[sam3->sidcount].attribute = - SE_GROUP_MANDATORY | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_ENABLED; - sam3->sidcount += 1; + + sam3->sids = talloc_array(sam, struct netr_SidAttr, + server_info->n_domain_groups); + NT_STATUS_HAVE_NO_MEMORY(sam3->sids); + + for (i=0; in_domain_groups; i++) { + if (dom_sid_in_domain(sam->domain_sid, server_info->domain_groups[i])) { + continue; } + sam3->sids[sam3->sidcount].sid = talloc_reference(sam3->sids,server_info->domain_groups[i]); + sam3->sids[sam3->sidcount].attribute = + SE_GROUP_MANDATORY | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_ENABLED; + sam3->sidcount += 1; + } + if (sam3->sidcount) { + sam3->base.user_flags |= NETLOGON_EXTRA_SIDS; + } else { + sam3->sids = NULL; } -#endif *_sam3 = sam3; return NT_STATUS_OK; -- cgit