s4-net: better error message on net setpassword
authorAndrew Tridgell <tridge@samba.org>
Sun, 22 Aug 2010 04:51:12 +0000 (14:51 +1000)
committerAndrew Tridgell <tridge@samba.org>
Sun, 22 Aug 2010 04:57:34 +0000 (14:57 +1000)
source4/scripting/python/samba/netcmd/setpassword.py

index e01fa23ab90219921337cd593c7830ed3cad4680..047a95afae2413741286d3d893e4757b14151d85 100644 (file)
@@ -26,6 +26,7 @@ from getpass import getpass
 from samba.auth import system_session
 from samba.samdb import SamDB
 from samba import gensec
+import ldb
 
 class cmd_setpassword(Command):
     """(Re)sets the password on a user account"""
@@ -74,6 +75,7 @@ class cmd_setpassword(Command):
             samdb.setpassword(filter, password,
                               force_change_at_next_login=must_change_at_next_login,
                               username=username)
-        except:
-            raise CommandError('Failed to set password for user "%s"' %
-                username)
+        except ldb.LdbError, (num, msg):
+            raise CommandError('Failed to set password for user "%s" - %s' %
+                               (username, msg))
+        print "Changed password OK"