s4-net: allow a username to be displayed in setpassword errors
authorAndrew Tridgell <tridge@samba.org>
Thu, 15 Apr 2010 07:15:25 +0000 (17:15 +1000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 16 Apr 2010 04:12:44 +0000 (14:12 +1000)
the filter is a bit too cryptic

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/scripting/python/samba/samdb.py

index 790cb2badc01a9e0838a08ef0b886bbfbf0d5a31..d41b3ec637860eef52f93b6e33d44f084fa87444 100644 (file)
@@ -153,7 +153,9 @@ pwdLastSet: 0
         else:
             self.transaction_commit()
 
-    def setpassword(self, filter, password, force_change_at_next_login=False):
+    def setpassword(self, filter, password,
+                    force_change_at_next_login=False,
+                    username=None):
         """Sets the password for a user
         
         Note: This call uses the "userPassword" attribute to set the password.
@@ -168,6 +170,9 @@ pwdLastSet: 0
         try:
             res = self.search(base=self.domain_dn(), scope=ldb.SCOPE_SUBTREE,
                               expression=filter, attrs=[])
+            if len(res) == 0:
+                print('Unable to find user "%s"' % (username or filter))
+                raise
             assert(len(res) == 1)
             user_dn = res[0].dn