diff options
author | Jean-François Micouleau <jfm@samba.org> | 2001-05-08 16:33:18 +0000 |
---|---|---|
committer | Jean-François Micouleau <jfm@samba.org> | 2001-05-08 16:33:18 +0000 |
commit | b6a6b4b02ef923ce71a8be8258ccee1cbb439c6f (patch) | |
tree | 4adc6c0fce3385d225493b43a544e12c43a5fd46 /source3/rpc_server | |
parent | acc0ca79a0d95160c2bcca40957b7d09c236c516 (diff) | |
download | samba-b6a6b4b02ef923ce71a8be8258ccee1cbb439c6f.tar.gz samba-b6a6b4b02ef923ce71a8be8258ccee1cbb439c6f.tar.bz2 samba-b6a6b4b02ef923ce71a8be8258ccee1cbb439c6f.zip |
fixes to the group mapping code.
Not ready yet.
J.F.
(This used to be commit 62a7a567fdea230b77cc97a3f74d868542c34700)
Diffstat (limited to 'source3/rpc_server')
-rw-r--r-- | source3/rpc_server/srv_samr.c | 31 | ||||
-rw-r--r-- | source3/rpc_server/srv_samr_nt.c | 56 |
2 files changed, 79 insertions, 8 deletions
diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 5012f0c483..9ab8ad5d15 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1189,6 +1189,36 @@ static BOOL api_samr_set_groupinfo(pipes_struct *p) } /******************************************************************* + api_samr_set_aliasinfo + ********************************************************************/ + +static BOOL api_samr_set_aliasinfo(pipes_struct *p) +{ + SAMR_Q_SET_ALIASINFO q_u; + SAMR_R_SET_ALIASINFO r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!samr_io_q_set_aliasinfo("", &q_u, data, 0)) { + DEBUG(0,("api_samr_set_aliasinfo: unable to unmarshall SAMR_Q_SET_ALIASINFO.\n")); + return False; + } + + r_u.status = _samr_set_aliasinfo(p, &q_u, &r_u); + + if (!samr_io_r_set_aliasinfo("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_set_aliasinfo: unable to marshall SAMR_R_SET_ALIASINFO.\n")); + return False; + } + + return True; +} + +/******************************************************************* api_samr_get_dom_pwinfo ********************************************************************/ @@ -1320,6 +1350,7 @@ static struct api_struct api_samr_cmds [] = {"SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, {"SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, {"SAMR_SET_GROUPINFO" , SAMR_SET_GROUPINFO , api_samr_set_groupinfo }, + {"SAMR_SET_ALIASINFO" , SAMR_SET_ALIASINFO , api_samr_set_aliasinfo }, {"SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user }, {"SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids }, {"SAMR_GET_DOM_PWINFO" , SAMR_GET_DOM_PWINFO , api_samr_get_dom_pwinfo }, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e09f93185c..693ef95df9 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -211,6 +211,8 @@ static BOOL jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, pdb_get_username(pwd), pdb_get_user_rid(pwd), pdb_get_acct_ctrl(pwd) )); (*num_entries)++; + + pdb_reset_sam(pwd); } pdb_endsampwent(); @@ -1411,6 +1413,8 @@ uint32 _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_U if (!find_policy_by_hnd(p, &domain_pol, NULL)) return NT_STATUS_INVALID_HANDLE; + pdb_init_sam(&sampass); + become_root(); ret=pdb_getsampwrid(sampass, user_rid); unbecome_root(); @@ -1540,6 +1544,8 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) return False; } + pdb_init_sam(&sampass); + become_root(); ret = pdb_getsampwrid(sampass, user_rid); unbecome_root(); @@ -2520,8 +2526,8 @@ uint32 _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_ DEBUG(10, ("sid is %s\n", alias_sid_str)); sid = (DOM_SID2 *)talloc(p->mem_ctx, sizeof(DOM_SID2) * num_uids); - if (sid == NULL) - return NT_STATUS_NO_SUCH_ALIAS; + if (num_uids!=0 && sid == NULL) + return NT_STATUS_NO_MEMORY; for (i = 0; i < num_uids; i++) { sid_copy(&temp_sid, &global_sam_sid); @@ -2581,7 +2587,7 @@ uint32 _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_ rid=talloc(p->mem_ctx, sizeof(uint32)*num_uids); attr=talloc(p->mem_ctx, sizeof(uint32)*num_uids); - if (rid==NULL || attr==NULL) + if (num_uids!=0 && (rid==NULL || attr==NULL)) return NT_STATUS_NO_MEMORY; for (i=0; i<num_uids; i++) { @@ -2859,10 +2865,6 @@ uint32 _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, SAM r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); - /* add the group to the mapping table */ - if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_ALIAS, NULL, NULL, SE_PRIV_NONE)) - return NT_STATUS_ACCESS_DENIED; - if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) return NT_STATUS_NO_MEMORY; @@ -2872,6 +2874,10 @@ uint32 _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, SAM sid_append_rid(&info->sid, r_u->rid); sid_to_string(sid_string, &info->sid); + /* add the group to the mapping table */ + if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_ALIAS, name, NULL, SE_PRIV_NONE)) + return NT_STATUS_ACCESS_DENIED; + /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, &r_u->alias_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2890,7 +2896,7 @@ uint32 _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAMR_ { DOM_SID group_sid; GROUP_MAP map; - uid_t *uid; + uid_t *uid=NULL; int num_uids=0; GROUP_INFO_CTR *ctr; @@ -2963,6 +2969,40 @@ uint32 _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_SE } /********************************************************************* + _samr_set_groupinfo + + update a domain group's comment. +*********************************************************************/ + +uint32 _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_SET_ALIASINFO *r_u) +{ + DOM_SID group_sid; + GROUP_MAP map; + ALIAS_INFO_CTR *ctr; + + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid)) + return NT_STATUS_INVALID_HANDLE; + + if (!get_local_group_from_sid(group_sid, &map)) + return NT_STATUS_NO_SUCH_GROUP; + + ctr=&q_u->ctr; + + switch (ctr->switch_value1) { + case 3: + unistr2_to_ascii(map.comment, &(ctr->alias.info3.uni_acct_desc), sizeof(map.comment)-1); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + } + + if(!add_mapping_entry(&map, TDB_REPLACE)) + return NT_STATUS_NO_SUCH_GROUP; + + return NT_STATUS_NO_PROBLEMO; +} + +/********************************************************************* _samr_get_dom_pwinfo *********************************************************************/ |