[SCM] Samba Shared Repository - branch master updated

Alexander Bokovoy ab at samba.org
Fri Sep 30 03:54:03 UTC 2016


The branch, master has been updated
       via  780a80c bug 12293: stop group.py throwing errors if group is unknown
       via  22da088 bug 12292: stop user.py throwing errors if user is unknown
      from  1f9501c winbind: Fix passing idmap failure from wb_sids2xids back to callers

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 780a80c28d491a1b9c76bda1b43ff8eb7aa346b1
Author: Rowland Penny <rpenny at samba.org>
Date:   Wed Sep 28 19:28:23 2016 +0100

    bug 12293: stop group.py throwing errors if group is unknown
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12293
    
    Signed-off-by: Rowland Penny <rpenny at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    
    Autobuild-User(master): Alexander Bokovoy <ab at samba.org>
    Autobuild-Date(master): Fri Sep 30 05:53:17 CEST 2016 on sn-devel-144

commit 22da0887b26f090dd39e864c139908ea33738a7b
Author: Rowland Penny <rpenny at samba.org>
Date:   Wed Sep 28 15:39:52 2016 +0100

    bug 12292: stop user.py throwing errors if user is unknown
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12292
    
    Signed-off-by: Rowland Penny <rpenny at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 python/samba/netcmd/group.py | 18 +++++++++++++++---
 python/samba/netcmd/user.py  | 19 ++++++++++++++++---
 2 files changed, 31 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/netcmd/group.py b/python/samba/netcmd/group.py
index 722bcc4..11f8773 100644
--- a/python/samba/netcmd/group.py
+++ b/python/samba/netcmd/group.py
@@ -169,11 +169,23 @@ Example2 deletes group Group2 from the local server.  The command is run under r
 
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
+        samdb = SamDB(url=H, session_info=system_session(),
+                      credentials=creds, lp=lp)
+
+        filter = ("(&(sAMAccountName=%s)(objectClass=group))" %
+                  groupname)
 
         try:
-            samdb = SamDB(url=H, session_info=system_session(),
-                          credentials=creds, lp=lp)
-            samdb.deletegroup(groupname)
+            res = samdb.search(base=samdb.domain_dn(),
+                               scope=ldb.SCOPE_SUBTREE,
+                               expression=filter,
+                               attrs=["dn"])
+            group_dn = res[0].dn
+        except IndexError:
+            raise CommandError('Unable to find group "%s"' % (groupname))
+
+        try:
+            samdb.delete(group_dn)
         except Exception, e:
             # FIXME: catch more specific exception
             raise CommandError('Failed to remove group "%s"' % groupname, e)
diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py
index 5adc287..4358170 100644
--- a/python/samba/netcmd/user.py
+++ b/python/samba/netcmd/user.py
@@ -406,10 +406,23 @@ Example2 shows how to delete a user in the domain against the local server.   su
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
 
+        samdb = SamDB(url=H, session_info=system_session(),
+                      credentials=creds, lp=lp)
+
+        filter = ("(&(sAMAccountName=%s)(sAMAccountType=805306368))" %
+                   username)
+
         try:
-            samdb = SamDB(url=H, session_info=system_session(),
-                          credentials=creds, lp=lp)
-            samdb.deleteuser(username)
+            res = samdb.search(base=samdb.domain_dn(),
+                               scope=ldb.SCOPE_SUBTREE,
+                               expression=filter,
+                               attrs=["dn"])
+            user_dn = res[0].dn
+        except IndexError:
+            raise CommandError('Unable to find user "%s"' % (username))
+
+        try:
+            samdb.delete(user_dn)
         except Exception, e:
             raise CommandError('Failed to remove user "%s"' % username, e)
         self.outf.write("Deleted user %s\n" % username)


-- 
Samba Shared Repository



More information about the samba-cvs mailing list