summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorJim McDonough <jmcd@samba.org>2005-10-20 20:40:47 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:05:08 -0500
commit1113cad9c0c81e9ecec3a0f4317c950943cfc62a (patch)
treefdafa600529a6bcc43cf283007630d8cd51b1151 /source3/rpc_server
parent6fc9098dcc1a1ef232b96f5d4c562bf340db8988 (diff)
downloadsamba-1113cad9c0c81e9ecec3a0f4317c950943cfc62a.tar.gz
samba-1113cad9c0c81e9ecec3a0f4317c950943cfc62a.tar.bz2
samba-1113cad9c0c81e9ecec3a0f4317c950943cfc62a.zip
r11236: Implement user rename for smbpasswd and ldap backends. Some cleanup on
tdb as well to make naming consistent. (This used to be commit ee91eb9a39cc5e3edd9e97eb040e7557930e4e62)
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_samr_nt.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index 45a77197ee..598f9db1da 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -2429,7 +2429,9 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A
static NTSTATUS set_user_info_7(const SAM_USER_INFO_7 *id7, SAM_ACCOUNT *pwd)
{
fstring new_name;
+ SAM_ACCOUNT *check_acct = NULL;
NTSTATUS rc;
+ BOOL check_rc;
if (id7 == NULL) {
DEBUG(5, ("set_user_info_7: NULL id7\n"));
@@ -2443,6 +2445,24 @@ static NTSTATUS set_user_info_7(const SAM_USER_INFO_7 *id7, SAM_ACCOUNT *pwd)
return NT_STATUS_ACCESS_DENIED;
}
+ /* check to see if the new username already exists. Note: we can't
+ reliably lock all backends, so there is potentially the
+ possibility that a user can be created in between this check and
+ the rename. The rename should fail, but may not get the
+ exact same failure status code. I think this is small enough
+ of a window for this type of operation and the results are
+ simply that the rename fails with a slightly different status
+ code (like UNSUCCESSFUL instead of ALREADY_EXISTS). */
+
+ pdb_init_sam(&check_acct);
+ check_rc = pdb_getsampwnam(check_acct, new_name);
+ pdb_free_sam(&check_acct);
+
+ if (check_rc == True) {
+ /* this account exists: say so */
+ return NT_STATUS_USER_EXISTS;
+ }
+
rc = pdb_rename_sam_account(pwd, new_name);
pdb_free_sam(&pwd);