diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 1 | ||||
-rw-r--r-- | source3/lib/sids.c | 11 | ||||
-rw-r--r-- | source3/rpc_parse/parse_samr.c | 22 | ||||
-rw-r--r-- | source3/rpc_server/srv_samr.c | 72 |
4 files changed, 90 insertions, 16 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index ff55331400..9c801297dc 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -303,6 +303,7 @@ BOOL generate_sam_sid(char *domain_name); BOOL map_domain_name_to_sid(DOM_SID *sid, char **nt_domain); BOOL map_domain_sid_to_name(DOM_SID *sid, char *nt_domain); BOOL split_domain_name(const char *fullname, char *domain, char *name); +BOOL enumdomains(char ***doms, uint32 *num_entries); /*The following definitions come from lib/signal.c */ diff --git a/source3/lib/sids.c b/source3/lib/sids.c index c75168ee56..4b1682afe9 100644 --- a/source3/lib/sids.c +++ b/source3/lib/sids.c @@ -596,3 +596,14 @@ BOOL split_domain_name(const char *fullname, char *domain, char *name) DEBUG(10,("name '%s' split into domain:%s and nt name:%s'\n", fullname, domain, name)); return True; } + +/************************************************************************** + enumerates all domains for which the SAM server is responsible +***************************************************************************/ +BOOL enumdomains(char ***doms, uint32 *num_entries) +{ + add_chars_to_array(num_entries, doms, global_sam_name); + add_chars_to_array(num_entries, doms, "Builtin"); + + return True; +} diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c index ab45152db0..90ae3e8fee 100644 --- a/source3/rpc_parse/parse_samr.c +++ b/source3/rpc_parse/parse_samr.c @@ -1136,7 +1136,7 @@ static BOOL make_sam_entry(SAM_ENTRY *sam, uint32 len_sam_name, uint32 rid) { if (sam == NULL) return False; - DEBUG(5,("make_sam_entry\n")); + DEBUG(10,("make_sam_entry: %d %d\n", len_sam_name, rid)); sam->rid = rid; make_uni_hdr(&(sam->hdr_name), len_sam_name); @@ -1278,9 +1278,6 @@ BOOL samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS *r_u, prs_struct prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users"); depth++; - r_u->sam = NULL; - r_u->uni_acct_name = NULL; - prs_align(ps); prs_uint32("next_idx ", ps, depth, &(r_u->next_idx )); @@ -2865,9 +2862,6 @@ BOOL samr_io_r_enum_domains(char *desc, SAMR_R_ENUM_DOMAINS *r_u, prs_struct *ps prs_debug(ps, depth, desc, "samr_io_r_enum_domains"); depth++; - r_u->sam = NULL; - r_u->uni_dom_name = NULL; - prs_align(ps); prs_uint32("next_idx ", ps, depth, &(r_u->next_idx )); @@ -2895,14 +2889,18 @@ BOOL samr_io_r_enum_domains(char *desc, SAMR_R_ENUM_DOMAINS *r_u, prs_struct *ps for (i = 0; i < r_u->num_entries2; i++) { + fstring tmp; + slprintf(tmp, sizeof(tmp)-1, "dom[%d]", i); prs_grow(ps); - sam_io_sam_entry("", &(r_u->sam[i]), ps, depth); + sam_io_sam_entry(tmp, &(r_u->sam[i]), ps, depth); } for (i = 0; i < r_u->num_entries2; i++) { + fstring tmp; + slprintf(tmp, sizeof(tmp)-1, "dom[%d]", i); prs_grow(ps); - smb_io_unistr2("", &(r_u->uni_dom_name[i]), r_u->sam[i].hdr_name.buffer, ps, depth); + smb_io_unistr2(tmp, &(r_u->uni_dom_name[i]), r_u->sam[i].hdr_name.buffer, ps, depth); } prs_align(ps); @@ -3028,9 +3026,6 @@ BOOL samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS *r_u, prs_stru prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups"); depth++; - r_u->sam = NULL; - r_u->uni_grp_name = NULL; - prs_align(ps); prs_uint32("next_idx ", ps, depth, &(r_u->next_idx )); @@ -3191,9 +3186,6 @@ BOOL samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES *r_u, prs_st prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases"); depth++; - r_u->sam = NULL; - r_u->uni_grp_name = NULL; - prs_align(ps); prs_uint32("next_idx ", ps, depth, &(r_u->next_idx )); diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index e85621a8a0..c3464380ed 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -627,6 +627,75 @@ static void api_samr_del_aliasmem( pipes_struct *p, prs_struct *data, prs_struct } /******************************************************************* + samr_reply_enum_domains + ********************************************************************/ +static void samr_reply_enum_domains(SAMR_Q_ENUM_DOMAINS *q_u, + prs_struct *rdata) +{ + SAMR_R_ENUM_DOMAINS r_e; + char **doms = NULL; + uint32 num_entries = 0; + + r_e.status = 0x0; + r_e.num_entries2 = 0; + + ZERO_STRUCT(r_e); + + r_e.status = 0x0; + + /* find the connection policy handle. */ + if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + { + r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + DEBUG(5,("samr_reply_enum_domains:\n")); + + if (!enumdomains(&doms, &num_entries)) + { + r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; + } + + if (r_e.status == 0x0) + { + make_samr_r_enum_domains(&r_e, + q_u->start_idx + num_entries, + num_entries, doms, r_e.status); + } + + /* store the response in the SMB stream */ + samr_io_r_enum_domains("", &r_e, rdata, 0); + + free_char_array(num_entries, doms); + + if (r_e.sam != NULL) + { + free(r_e.sam); + } + + if (r_e.uni_dom_name != NULL) + { + free(r_e.uni_dom_name); + } + + DEBUG(5,("samr_enum_domains: %d\n", __LINE__)); +} + +/******************************************************************* + api_samr_enum_domains + ********************************************************************/ +static void api_samr_enum_domains( pipes_struct *p, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_ENUM_DOMAINS q_e; + + /* grab the samr open */ + samr_io_q_enum_domains("", &q_e, data, 0); + + /* construct reply. */ + samr_reply_enum_domains(&q_e, rdata); +} + +/******************************************************************* samr_reply_enum_dom_groups ********************************************************************/ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, @@ -693,7 +762,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, } /******************************************************************* - api_samr_enum_dom_aliases + api_samr_enum_dom_groups ********************************************************************/ static void api_samr_enum_dom_groups( pipes_struct *p, prs_struct *data, prs_struct *rdata) { @@ -2933,6 +3002,7 @@ static struct api_struct api_samr_cmds [] = { "SAMR_CLOSE_HND" , SAMR_CLOSE_HND , api_samr_close_hnd }, { "SAMR_CONNECT" , SAMR_CONNECT , api_samr_connect }, { "SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon }, + { "SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains }, { "SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users }, { "SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, { "SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, |