From e98f56373bca0efc200bc3a4263477e1790a746b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Feb 2005 14:14:44 +0000 Subject: r5262: Fix server_role in the samr_query_dom_info calls. When we are a BDC we should not say we are a PDC. Guenther (This used to be commit 6cdf3b97de2c28ac92f972621b0ce04c1c80cea5) --- source3/include/rpc_samr.h | 4 ++-- source3/rpc_parse/parse_samr.c | 12 ++++++------ source3/rpc_server/srv_samr_nt.c | 29 +++++++++++++++++++++++------ source3/rpcclient/cmd_samr.c | 35 ++++++++++++++++++++++++++++++++--- 4 files changed, 63 insertions(+), 17 deletions(-) diff --git a/source3/include/rpc_samr.h b/source3/include/rpc_samr.h index a007bcd2e5..e041ee26f0 100644 --- a/source3/include/rpc_samr.h +++ b/source3/include/rpc_samr.h @@ -540,7 +540,7 @@ typedef struct sam_unknown_info_6_info typedef struct sam_unknown_info_7_info { - uint16 unknown_0; /* 0x0003 */ + uint16 server_role; } SAM_UNK_INFO_7; @@ -580,7 +580,7 @@ typedef struct sam_unknown_info_2_inf UINT64_S seq_num; uint32 unknown_4; /* 0x0000 0001 */ - uint32 unknown_5; /* 0x0000 0003 */ + uint32 server_role; uint32 unknown_6; /* 0x0000 0001 */ uint32 num_domain_usrs; /* number of users in domain */ uint32 num_domain_grps; /* number of domain groups in domain */ diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c index 748ee1fb7c..27570ae821 100644 --- a/source3/rpc_parse/parse_samr.c +++ b/source3/rpc_parse/parse_samr.c @@ -564,9 +564,9 @@ static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6, inits a structure. ********************************************************************/ -void init_unk_info7(SAM_UNK_INFO_7 * u_7) +void init_unk_info7(SAM_UNK_INFO_7 * u_7, uint32 server_role) { - u_7->unknown_0 = 0x0003; + u_7->server_role = server_role; } /******************************************************************* @@ -582,7 +582,7 @@ static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7, prs_debug(ps, depth, desc, "sam_io_unk_info7"); depth++; - if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */ + if(!prs_uint16("server_role", ps, depth, &u_7->server_role)) return False; return True; @@ -697,7 +697,7 @@ inits a structure. void init_unk_info2(SAM_UNK_INFO_2 * u_2, const char *comment, const char *domain, const char *server, - uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout) + uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias, NTTIME nt_logout, uint32 server_role) { u_2->logout.low = nt_logout.low; u_2->logout.high = nt_logout.high; @@ -707,7 +707,7 @@ void init_unk_info2(SAM_UNK_INFO_2 * u_2, u_2->unknown_4 = 0x00000001; - u_2->unknown_5 = 0x00000003; + u_2->server_role = server_role; u_2->unknown_6 = 0x00000001; u_2->num_domain_usrs = num_users; u_2->num_domain_grps = num_groups; @@ -754,7 +754,7 @@ static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2, if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */ return False; - if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */ + if(!prs_uint32("server_role ", ps, depth, &u_2->server_role)) return False; if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */ return False; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1d4569e39f..4e7d239b2c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2072,6 +2072,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA NTTIME nt_logout; uint32 account_policy_temp; + uint32 server_role; uint32 num_users=0, num_groups=0, num_aliases=0; @@ -2136,9 +2137,13 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA unix_to_nt_time_abs(&nt_logout, u_logout); + server_role = ROLE_DOMAIN_PDC; + if (lp_server_role() == ROLE_DOMAIN_BDC) + server_role = ROLE_DOMAIN_BDC; + /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, "", lp_workgroup(), global_myname(), (uint32) time(NULL), - num_users, num_groups, num_aliases, nt_logout); + init_unk_info2(&ctr->info.inf2, lp_serverstring(), lp_workgroup(), global_myname(), time(NULL), + num_users, num_groups, num_aliases, nt_logout, server_role); break; case 0x03: pdb_get_account_policy(AP_TIME_TO_LOGOUT, (unsigned int *)&u_logout); @@ -2153,7 +2158,11 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA init_unk_info6(&ctr->info.inf6); break; case 0x07: - init_unk_info7(&ctr->info.inf7); + server_role = ROLE_DOMAIN_PDC; + if (lp_server_role() == ROLE_DOMAIN_BDC) + server_role = ROLE_DOMAIN_BDC; + + init_unk_info7(&ctr->info.inf7, server_role); break; case 0x08: init_unk_info8(&ctr->info.inf8, (uint32) time(NULL)); @@ -4546,6 +4555,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW uint32 num_users=0, num_groups=0, num_aliases=0; uint32 account_policy_temp; + uint32 server_role; if ((ctr = TALLOC_ZERO_P(p->mem_ctx, SAM_UNK_CTR)) == NULL) return NT_STATUS_NO_MEMORY; @@ -4607,9 +4617,13 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW unix_to_nt_time_abs(&nt_logout, u_logout); + server_role = ROLE_DOMAIN_PDC; + if (lp_server_role() == ROLE_DOMAIN_BDC) + server_role = ROLE_DOMAIN_BDC; + /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, "", lp_workgroup(), global_myname(), (uint32) time(NULL), - num_users, num_groups, num_aliases, nt_logout); + init_unk_info2(&ctr->info.inf2, lp_serverstring(), lp_workgroup(), global_myname(), time(NULL), + num_users, num_groups, num_aliases, nt_logout, server_role); break; case 0x03: pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); @@ -4626,7 +4640,10 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW init_unk_info6(&ctr->info.inf6); break; case 0x07: - init_unk_info7(&ctr->info.inf7); + server_role = ROLE_DOMAIN_PDC; + if (lp_server_role() == ROLE_DOMAIN_BDC) + server_role = ROLE_DOMAIN_BDC; + init_unk_info7(&ctr->info.inf7, server_role); break; case 0x08: init_unk_info8(&ctr->info.inf8, (uint32) time(NULL)); diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index a69a0cb73a..331353aee7 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -141,6 +141,27 @@ static const char *display_time(NTTIME nttime) return (string); } +static const char* server_role_str(uint32 server_role) +{ + switch(server_role) { + case ROLE_STANDALONE: + return strdup("ROLE_STANDALONE"); + break; + case ROLE_DOMAIN_MEMBER: + return strdup("ROLE_DOMAIN_MEMBER"); + break; + case ROLE_DOMAIN_BDC: + return strdup("ROLE_DOMAIN_BDC"); + break; + case ROLE_DOMAIN_PDC: + return strdup("ROLE_DOMAIN_PDC"); + break; + default: + return strdup("Unknown -- internal error?"); + break; + } +} + static void display_sam_unk_info_1(SAM_UNK_INFO_1 *info1) { @@ -159,10 +180,10 @@ static void display_sam_unk_info_2(SAM_UNK_INFO_2 *info2) fstring name; unistr2_to_ascii(name, &info2->uni_domain, sizeof(name) - 1); - printf("Domain:\t%s\n", name); + printf("Domain:\t\t%s\n", name); unistr2_to_ascii(name, &info2->uni_server, sizeof(name) - 1); - printf("Server:\t%s\n", name); + printf("Server:\t\t%s\n", name); unistr2_to_ascii(name, &info2->uni_comment, sizeof(name) - 1); printf("Comment:\t%s\n", name); @@ -176,10 +197,15 @@ static void display_sam_unk_info_2(SAM_UNK_INFO_2 *info2) printf("Force Logoff:\t%d\n", (int)nt_time_to_unix_abs(&info2->logout)); printf("Unknown 4:\t0x%x\n", info2->unknown_4); - printf("Unknown 5:\t0x%x\n", info2->unknown_5); + printf("Server Role:\t%s\n", server_role_str(info2->server_role)); printf("Unknown 6:\t0x%x\n", info2->unknown_6); } +static void display_sam_unk_info_7(SAM_UNK_INFO_7 *info7) +{ + printf("Server Role:\t%s\n", server_role_str(info7->server_role)); +} + static void display_sam_unk_info_8(SAM_UNK_INFO_8 *info8) { printf("Sequence No:\t%d\n", info8->seq_num.low); @@ -1161,6 +1187,9 @@ static NTSTATUS cmd_samr_query_dominfo(struct cli_state *cli, case 2: display_sam_unk_info_2(&ctr.info.inf2); break; + case 7: + display_sam_unk_info_7(&ctr.info.inf7); + break; case 8: display_sam_unk_info_8(&ctr.info.inf8); break; -- cgit