s4-samba-tool: give a bit better error on user delete failure
authorAndrew Tridgell <tridge@samba.org>
Fri, 1 Apr 2011 04:59:15 +0000 (15:59 +1100)
committerAndrew Tridgell <tridge@samba.org>
Mon, 4 Apr 2011 00:30:30 +0000 (10:30 +1000)
source4/scripting/python/samba/netcmd/user.py

index bbc972bcc7e488c570adb65a125f13ffc041d7e1..a5750b50107ce16f6ef034bf57fc6a10fd093c9d 100644 (file)
@@ -24,6 +24,7 @@ from samba.net import Net
 
 from samba.netcmd import (
     Command,
+    CommandError,
     SuperCommand,
     )
 
@@ -64,7 +65,10 @@ class cmd_user_delete(Command):
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp, fallback_machine=True)
         net = Net(creds, lp, server=credopts.ipaddress)
-        net.delete_user(name)
+        try:
+            net.delete_user(name)
+        except RuntimeError, msg:
+            raise CommandError("Failed to delete user %s: %s" % (name, msg))
 
 
 class cmd_user(SuperCommand):