diff options
author | Jim McDonough <jmcd@samba.org> | 2005-10-20 20:40:47 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:05:08 -0500 |
commit | 1113cad9c0c81e9ecec3a0f4317c950943cfc62a (patch) | |
tree | fdafa600529a6bcc43cf283007630d8cd51b1151 /source3/passdb/pdb_ldap.c | |
parent | 6fc9098dcc1a1ef232b96f5d4c562bf340db8988 (diff) | |
download | samba-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/passdb/pdb_ldap.c')
-rw-r--r-- | source3/passdb/pdb_ldap.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index ea21a03b51..92ef513325 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -1870,6 +1870,52 @@ static NTSTATUS ldapsam_update_sam_account(struct pdb_methods *my_methods, SAM_A return NT_STATUS_OK; } +/*************************************************************************** + Renames a SAM_ACCOUNT + - The "rename user script" has full responsibility for changing everything +***************************************************************************/ + +static NTSTATUS ldapsam_rename_sam_account(struct pdb_methods *my_methods, + SAM_ACCOUNT *old_acct, + const char *newname) +{ + const char *oldname; + int rc; + pstring rename_script; + + if (!old_acct) { + DEBUG(0, ("ldapsam_rename_sam_account: old_acct was NULL!\n")); + return NT_STATUS_INVALID_PARAMETER; + } + if (!newname) { + DEBUG(0, ("ldapsam_rename_sam_account: newname was NULL!\n")); + return NT_STATUS_INVALID_PARAMETER; + } + + oldname = pdb_get_username(old_acct); + + /* rename the posix user */ + pstrcpy(rename_script, lp_renameuser_script()); + + if (!(*rename_script)) + return NT_STATUS_ACCESS_DENIED; + + DEBUG (3, ("ldapsam_rename_sam_account: Renaming user %s to %s.\n", + oldname, newname)); + + pstring_sub(rename_script, "%unew", newname); + pstring_sub(rename_script, "%uold", oldname); + rc = smbrun(rename_script, NULL); + + DEBUG(rc ? 0 : 3,("Running the command `%s' gave %d\n", + rename_script, rc)); + + if (rc) + return NT_STATUS_UNSUCCESSFUL; + + return NT_STATUS_OK; +} + /********************************************************************** Helper function to determine for update_sam_account whether we need LDAP modification. @@ -4203,6 +4249,7 @@ static NTSTATUS pdb_init_ldapsam_common(PDB_CONTEXT *pdb_context, PDB_METHODS ** (*pdb_method)->add_sam_account = ldapsam_add_sam_account; (*pdb_method)->update_sam_account = ldapsam_update_sam_account; (*pdb_method)->delete_sam_account = ldapsam_delete_sam_account; + (*pdb_method)->rename_sam_account = ldapsam_rename_sam_account; (*pdb_method)->getgrsid = ldapsam_getgrsid; (*pdb_method)->getgrgid = ldapsam_getgrgid; |