From: Douglas Bagnall Date: Thu, 1 Feb 2018 21:35:25 +0000 (+1300) Subject: python samdb.newuser(): use user DN not samaccountname to set password X-Git-Tag: tevent-0.9.36~181 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d8aa50b217b16b7e809fa5d59b6240a5671e86b8;p=thirdparty%2Fsamba.git python samdb.newuser(): use user DN not samaccountname to set password This is noticably faster in cases (e.g. tests) where the same user is added and deleted many times. The rreason is samaccountname is retained for deleted objects, so the search finds multiple objects that need to be filtered out internally. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/samdb.py b/python/samba/samdb.py index d1048a74e14..7f52a5e56f8 100644 --- a/python/samba/samdb.py +++ b/python/samba/samdb.py @@ -459,7 +459,9 @@ member: %s # Sets the password for it if setpassword: - self.setpassword("(samAccountName=%s)" % ldb.binary_encode(username), password, + self.setpassword(("(distinguishedName=%s)" % + ldb.binary_encode(user_dn)), + password, force_password_change_at_next_login_req) except: self.transaction_cancel()