diff options
author | Volker Lendecke <vlendec@samba.org> | 2003-06-11 20:42:10 +0000 |
---|---|---|
committer | Volker Lendecke <vlendec@samba.org> | 2003-06-11 20:42:10 +0000 |
commit | 43d306011fe0497dabdf6f43a0d120900fd96e6d (patch) | |
tree | fb2b32378a2a7c93aadc70c5e7d05779928a3c36 /source/rpc_server | |
parent | d1eac2c75856f8f1dec8d429feb24a5f05fa6ca8 (diff) | |
download | samba-43d306011fe0497dabdf6f43a0d120900fd96e6d.tar.gz samba-43d306011fe0497dabdf6f43a0d120900fd96e6d.tar.xz samba-43d306011fe0497dabdf6f43a0d120900fd96e6d.zip |
Set the user's primary unix group from usrmgr.exe.
This part of a fix to bug#45.
Volker
Diffstat (limited to 'source/rpc_server')
-rw-r--r-- | source/rpc_server/srv_samr_nt.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source/rpc_server/srv_samr_nt.c b/source/rpc_server/srv_samr_nt.c index ee496126ada..40f6579e274 100644 --- a/source/rpc_server/srv_samr_nt.c +++ b/source/rpc_server/srv_samr_nt.c @@ -2731,6 +2731,41 @@ static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, DOM_SID *sid) } /******************************************************************* + The GROUPSID field in the SAM_ACCOUNT changed. Try to tell unix. + ********************************************************************/ +static BOOL set_unix_primary_group(SAM_ACCOUNT *sampass) +{ + struct group *grp; + gid_t gid; + + if (!NT_STATUS_IS_OK(sid_to_gid(pdb_get_group_sid(sampass), + &gid))) { + DEBUG(2,("Could not get gid for primary group of " + "user %s\n", pdb_get_username(sampass))); + return False; + } + + grp = getgrgid(gid); + + if (grp == NULL) { + DEBUG(2,("Could not find primary group %d for " + "user %s\n", gid, pdb_get_username(sampass))); + return False; + } + + if (smb_set_primary_group(grp->gr_name, + pdb_get_username(sampass)) != 0) { + DEBUG(2,("Could not set primary group for user %s to " + "%s\n", + pdb_get_username(sampass), grp->gr_name)); + return False; + } + + return True; +} + + +/******************************************************************* set_user_info_21 ********************************************************************/ @@ -2759,6 +2794,9 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, DOM_SID *sid) * id21. I don't know if they need to be set. --jerry */ + if (IS_SAM_CHANGED(pwd, PDB_GROUPSID)) + set_unix_primary_group(pwd); + /* write the change out */ if(!pdb_update_sam_account(pwd)) { pdb_free_sam(&pwd); @@ -2826,6 +2864,9 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) ZERO_STRUCT(plaintext_buf); + if (IS_SAM_CHANGED(pwd, PDB_GROUPSID)) + set_unix_primary_group(pwd); + if(!pdb_update_sam_account(pwd)) { pdb_free_sam(&pwd); return False; |