diff options
-rw-r--r-- | source3/include/rpc_samr.h | 32 | ||||
-rw-r--r-- | source3/rpc_parse/parse_samr.c | 125 | ||||
-rw-r--r-- | source3/rpc_server/srv_samr_nt.c | 16 | ||||
-rw-r--r-- | source3/rpcclient/cmd_samr.c | 62 |
4 files changed, 219 insertions, 16 deletions
diff --git a/source3/include/rpc_samr.h b/source3/include/rpc_samr.h index 7aea1b23c3..833a1358ff 100644 --- a/source3/include/rpc_samr.h +++ b/source3/include/rpc_samr.h @@ -542,10 +542,8 @@ typedef struct sam_unknown_info_3_info typedef struct sam_unknown_info_6_info { - uint32 unknown_0; /* 0x0000 0000 */ - - uint32 ptr_0; /* pointer to unknown structure */ - uint8 padding[12]; /* 12 bytes zeros */ + UNIHDR hdr_server; /* server name unicode header */ + UNISTR2 uni_server; /* server name unicode string */ } SAM_UNK_INFO_6; @@ -562,6 +560,12 @@ typedef struct sam_unknown_info_8_info } SAM_UNK_INFO_8; +typedef struct sam_unknown_info_9_info +{ + uint32 unknown; + +} SAM_UNK_INFO_9; + typedef struct sam_unknown_info_12_inf { NTTIME duration; @@ -570,6 +574,15 @@ typedef struct sam_unknown_info_12_inf } SAM_UNK_INFO_12; +typedef struct sam_unknown_info_13_info +{ + UINT64_S seq_num; + NTTIME domain_create_time; + uint32 unknown1; + uint32 unknown2; + +} SAM_UNK_INFO_13; + typedef struct sam_unknown_info_5_inf { UNIHDR hdr_domain; /* domain name unicode header */ @@ -577,6 +590,14 @@ typedef struct sam_unknown_info_5_inf } SAM_UNK_INFO_5; +typedef struct sam_unknown_info_4_inf +{ + UNIHDR hdr_comment; /* comment according to samba4 idl */ + UNISTR2 uni_comment; /* comment unicode string */ + +} SAM_UNK_INFO_4; + + typedef struct sam_unknown_info_2_inf { NTTIME logout; /* whether users are forcibly disconnected when logon hours expire */ @@ -621,11 +642,14 @@ typedef struct sam_unknown_ctr_info SAM_UNK_INFO_1 inf1; SAM_UNK_INFO_2 inf2; SAM_UNK_INFO_3 inf3; + SAM_UNK_INFO_4 inf4; SAM_UNK_INFO_5 inf5; SAM_UNK_INFO_6 inf6; SAM_UNK_INFO_7 inf7; SAM_UNK_INFO_8 inf8; + SAM_UNK_INFO_9 inf9; SAM_UNK_INFO_12 inf12; + SAM_UNK_INFO_13 inf13; } info; diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c index 287e79f1b4..370e29ccad 100644 --- a/source3/rpc_parse/parse_samr.c +++ b/source3/rpc_parse/parse_samr.c @@ -529,11 +529,10 @@ static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3, inits a structure. ********************************************************************/ -void init_unk_info6(SAM_UNK_INFO_6 * u_6) +void init_unk_info6(SAM_UNK_INFO_6 * u_6, const char *server) { - u_6->unknown_0 = 0x00000000; - u_6->ptr_0 = 1; - memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */ + init_unistr2(&u_6->uni_server, server, UNI_FLAGS_NONE); + init_uni_hdr(&u_6->hdr_server, &u_6->uni_server); } /******************************************************************* @@ -549,11 +548,42 @@ static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6, prs_debug(ps, depth, desc, "sam_io_unk_info6"); depth++; - if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */ + if(!smb_io_unihdr("hdr_server", &u_6->hdr_server, ps, depth)) return False; - if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */ + + if(!smb_io_unistr2("uni_server", &u_6->uni_server, u_6->hdr_server.buffer, ps, depth)) + return False; + + return True; +} + +/******************************************************************* +inits a structure. +********************************************************************/ + +void init_unk_info4(SAM_UNK_INFO_4 * u_4,const char *comment) +{ + init_unistr2(&u_4->uni_comment, comment, UNI_FLAGS_NONE); + init_uni_hdr(&u_4->hdr_comment, &u_4->uni_comment); +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ + +static BOOL sam_io_unk_info4(const char *desc, SAM_UNK_INFO_4 * u_4, + prs_struct *ps, int depth) +{ + if (u_4 == NULL) + return False; + + prs_debug(ps, depth, desc, "sam_io_unk_info4"); + depth++; + + if(!smb_io_unihdr("hdr_comment", &u_4->hdr_comment, ps, depth)) return False; - if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */ + + if(!smb_io_unistr2("uni_comment", &u_4->uni_comment, u_4->hdr_comment.buffer, ps, depth)) return False; return True; @@ -620,6 +650,33 @@ static BOOL sam_io_unk_info8(const char *desc, SAM_UNK_INFO_8 * u_8, return True; } +/******************************************************************* +inits a structure. +********************************************************************/ + +void init_unk_info9(SAM_UNK_INFO_9 * u_9, uint32 unknown) +{ + u_9->unknown = unknown; +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ + +static BOOL sam_io_unk_info9(const char *desc, SAM_UNK_INFO_9 * u_9, + prs_struct *ps, int depth) +{ + if (u_9 == NULL) + return False; + + prs_debug(ps, depth, desc, "sam_io_unk_info9"); + depth++; + + if (!prs_uint32("unknown", ps, depth, &u_9->unknown)) + return False; + + return True; +} /******************************************************************* inits a structure. @@ -694,6 +751,48 @@ static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5, inits a structure. ********************************************************************/ +void init_unk_info13(SAM_UNK_INFO_13 * u_13, uint32 seq_num) +{ + unix_to_nt_time(&u_13->domain_create_time, 0); + u_13->seq_num.low = seq_num; + u_13->seq_num.high = 0x0000; + u_13->unknown1 = 0; + u_13->unknown2 = 0; +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ + +static BOOL sam_io_unk_info13(const char *desc, SAM_UNK_INFO_13 * u_13, + prs_struct *ps, int depth) +{ + if (u_13 == NULL) + return False; + + prs_debug(ps, depth, desc, "sam_io_unk_info13"); + depth++; + + if (!prs_uint64("seq_num", ps, depth, &u_13->seq_num)) + return False; + + if(!smb_io_time("domain_create_time", &u_13->domain_create_time, ps, depth)) + return False; + + if (!prs_uint32("unknown1", ps, depth, &u_13->unknown1)) + return False; + if (!prs_uint32("unknown2", ps, depth, &u_13->unknown2)) + return False; + + + + return True; +} + +/******************************************************************* +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 server_role) @@ -867,10 +966,18 @@ BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u, return False; switch (r_u->switch_value) { + case 0x0d: + if(!sam_io_unk_info13("unk_inf13", &r_u->ctr->info.inf13, ps, depth)) + return False; + break; case 0x0c: if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth)) return False; break; + case 0x09: + if(!sam_io_unk_info9("unk_inf9",&r_u->ctr->info.inf9, ps,depth)) + return False; + break; case 0x08: if(!sam_io_unk_info8("unk_inf8",&r_u->ctr->info.inf8, ps,depth)) return False; @@ -887,6 +994,10 @@ BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u, if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth)) return False; break; + case 0x04: + if(!sam_io_unk_info4("unk_inf4",&r_u->ctr->info.inf4, ps,depth)) + return False; + break; case 0x03: if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth)) return False; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d672ab4a5b..035f838048 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2304,7 +2304,10 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA init_unk_info5(&ctr->info.inf5, get_global_sam_name()); break; case 0x06: - init_unk_info6(&ctr->info.inf6); + /* NT returns its own name when a PDC. win2k and later + * only the name of the PDC if itself is a BDC (samba4 + * idl) */ + init_unk_info6(&ctr->info.inf6, global_myname()); break; case 0x07: server_role = ROLE_DOMAIN_PDC; @@ -4712,8 +4715,8 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, ********************************************************************/ NTSTATUS _samr_query_domain_info2(pipes_struct *p, - SAMR_Q_QUERY_DOMAIN_INFO2 *q_u, - SAMR_R_QUERY_DOMAIN_INFO2 *r_u) + SAMR_Q_QUERY_DOMAIN_INFO2 *q_u, + SAMR_R_QUERY_DOMAIN_INFO2 *r_u) { struct samr_info *info = NULL; SAM_UNK_CTR *ctr; @@ -4805,7 +4808,10 @@ NTSTATUS _samr_query_domain_info2(pipes_struct *p, init_unk_info5(&ctr->info.inf5, get_global_sam_name()); break; case 0x06: - init_unk_info6(&ctr->info.inf6); + /* NT returns its own name when a PDC. win2k and later + * only the name of the PDC if itself is a BDC (samba4 + * idl) */ + init_unk_info6(&ctr->info.inf6, global_myname()); break; case 0x07: server_role = ROLE_DOMAIN_PDC; @@ -4849,7 +4855,7 @@ NTSTATUS _samr_query_domain_info2(pipes_struct *p, } /******************************************************************* - _samr_ + _samr_set_dom_info ********************************************************************/ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R_SET_DOMAIN_INFO *r_u) diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index ca0b6e9624..cbf638e7e6 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -208,6 +208,35 @@ static void display_sam_unk_info_2(SAM_UNK_INFO_2 *info2) printf("Unknown 6:\t0x%x\n", info2->unknown_6); } +static void display_sam_unk_info_3(SAM_UNK_INFO_3 *info3) +{ + printf("Force Logoff:\t%d\n", (int)nt_time_to_unix_abs(&info3->logout)); +} + +static void display_sam_unk_info_4(SAM_UNK_INFO_4 *info4) +{ + fstring name; + + unistr2_to_ascii(name, &info4->uni_comment, sizeof(name) - 1); + printf("Comment:\t%s\n", name); +} + +static void display_sam_unk_info_5(SAM_UNK_INFO_5 *info5) +{ + fstring name; + + unistr2_to_ascii(name, &info5->uni_domain, sizeof(name) - 1); + printf("Domain:\t\t%s\n", name); +} + +static void display_sam_unk_info_6(SAM_UNK_INFO_6 *info6) +{ + fstring name; + + unistr2_to_ascii(name, &info6->uni_server, sizeof(name) - 1); + printf("Server:\t\t%s\n", name); +} + static void display_sam_unk_info_7(SAM_UNK_INFO_7 *info7) { printf("Server Role:\t%s\n", server_role_str(info7->server_role)); @@ -218,7 +247,11 @@ static void display_sam_unk_info_8(SAM_UNK_INFO_8 *info8) printf("Sequence No:\t%d\n", info8->seq_num.low); printf("Domain Create Time:\t%s\n", http_timestring(nt_time_to_unix(&info8->domain_create_time))); +} +static void display_sam_unk_info_9(SAM_UNK_INFO_9 *info9) +{ + printf("unknown:\t%d (0x%08x)\n", info9->unknown, info9->unknown); } static void display_sam_unk_info_12(SAM_UNK_INFO_12 *info12) @@ -228,6 +261,16 @@ static void display_sam_unk_info_12(SAM_UNK_INFO_12 *info12) printf("Lockout after bad attempts: %d\n", info12->bad_attempt_lockout); } +static void display_sam_unk_info_13(SAM_UNK_INFO_13 *info13) +{ + printf("Sequence No:\t%d\n", info13->seq_num.low); + printf("Domain Create Time:\t%s\n", + http_timestring(nt_time_to_unix(&info13->domain_create_time))); + printf("Unknown1:\t%d\n", info13->unknown1); + printf("Unknown2:\t%d\n", info13->unknown2); + +} + static void display_sam_info_1(SAM_ENTRY1 *e1, SAM_STR1 *s1) { fstring tmp; @@ -1367,15 +1410,34 @@ static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli, case 2: display_sam_unk_info_2(&ctr.info.inf2); break; + case 3: + display_sam_unk_info_3(&ctr.info.inf3); + break; + case 4: + display_sam_unk_info_4(&ctr.info.inf4); + break; + case 5: + display_sam_unk_info_5(&ctr.info.inf5); + break; + case 6: + display_sam_unk_info_6(&ctr.info.inf6); + break; case 7: display_sam_unk_info_7(&ctr.info.inf7); break; case 8: display_sam_unk_info_8(&ctr.info.inf8); break; + case 9: + display_sam_unk_info_9(&ctr.info.inf9); + break; case 12: display_sam_unk_info_12(&ctr.info.inf12); break; + case 13: + display_sam_unk_info_13(&ctr.info.inf13); + break; + default: printf("cannot display domain info for switch value %d\n", switch_level); |