allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [02/11] git commit: [#7388] ticket:591 Handle case when no old password is provided
Date Fri, 23 May 2014 17:54:55 GMT
[#7388] ticket:591 Handle case when no old password is provided


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/505399b5
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/505399b5
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/505399b5

Branch: refs/heads/master
Commit: 505399b5a5b16da6e7d00d16c5dbc79d94c9444f
Parents: e599209
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri May 16 11:22:39 2014 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri May 23 17:53:44 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/505399b5/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 4575ab7..aaf9c10 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -367,10 +367,16 @@ class LdapAuthenticationProvider(AuthenticationProvider):
         return M.User.query.get(username=username, disabled=False)
 
     def set_password(self, user, old_password, new_password):
+        dn = 'uid=%s,%s' % (user.username, config['auth.ldap.suffix'])
+        if old_password:
+            ldap_ident = dn
+            ldap_pass = old_password.encode('utf-8')
+        else:
+            ldap_ident = config['auth.ldap.admin_dn']
+            ldap_pass = config['auth.ldap.admin_password']
         try:
-            dn = 'uid=%s,%s' % (user.username, config['auth.ldap.suffix'])
             con = ldap.initialize(config['auth.ldap.server'])
-            con.bind_s(dn, old_password.encode('utf-8'))
+            con.bind_s(ldap_ident, ldap_pass)
             new_password = self._encode_password(new_password)
             con.modify_s(
                 dn, [(ldap.MOD_REPLACE, 'userPassword', new_password)])


Mime
View raw message