Fix for delete user on Samba-3.0.4, LDAP backend

Jianliang Lu j.lu at tiesse.com
Thu May 13 10:56:20 GMT 2004


For LDAP backend if we use "delete user script = smbldap-userdel", that will 
not only delete the posix side user, it will delete samba side user as well. 
So delete user will get error using usrmgr. Following fix will solve this 
probem.

Fix:

--- rpc_server/srv_samr_nt.c.orig   Tue May 11 15:30:55 2004
+++ rpc_server/srv_samr_nt.c    Thu May 13 12:28:31 2004
@@ -3680,11 +3680,16 @@
     */
    smb_delete_user(pdb_get_username(sam_pass));

+   /* check if the user samba side exists before trying to delete */
+   if(!pdb_getsampwsid(sam_pass, &user_sid)) {
+       DEBUG(10,("_samr_delete_dom_user:User %s deleted by winbind or del 
script.\n", sid_string_static(&user_sid)));
+   } else {
    /* and delete the samba side */
-   if (!pdb_delete_sam_account(sam_pass)) {
-       DEBUG(5,("_samr_delete_dom_user:Failed to delete entry for user %
s.\n",
pdb_get_username(sam_pass)));
-       pdb_free_sam(&sam_pass);
-       return NT_STATUS_CANNOT_DELETE;
+       if (!pdb_delete_sam_account(sam_pass)) {
+           DEBUG(5,("_samr_delete_dom_user:Failed to delete entry for user %
s.\
n", pdb_get_username(sam_pass)));
+           pdb_free_sam(&sam_pass);
+           return NT_STATUS_CANNOT_DELETE;
+       }
    }

    pdb_free_sam(&sam_pass);

--------
Jianliang Lu
TieSse s.p.a.     Ivrea (To) - Italy
j.lu at tiesse.com   luj at libero.it
http://www.tiesse.com


More information about the samba-technical mailing list