mod_auth_ldap: Implement password change
authorKim Alvefur <zash@zash.se>
Tue, 17 Sep 2013 16:02:33 +0200
changeset 1192 db4085433e5f
parent 1191 1818a7f08580
child 1193 bbe278a56b0a
mod_auth_ldap: Implement password change
mod_auth_ldap/mod_auth_ldap.lua
--- a/mod_auth_ldap/mod_auth_ldap.lua	Wed Sep 11 21:43:49 2013 +0200
+++ b/mod_auth_ldap/mod_auth_ldap.lua	Tue Sep 17 16:02:33 2013 +0200
@@ -40,9 +40,15 @@
 function provider.user_exists(username)
 	return not not get_user(username);
 end
-
-function provider.set_password(username, password) return nil, "Passwords unavailable for LDAP."; end
-function provider.create_user(username, password) return nil, "Account creation/modification not available with LDAP."; end
+function provider.set_password(username, password)
+	local dn, attr = get_user(username);
+	if not dn then return nil, attr end
+	if attr.password ~= password then
+		ld:modify(dn, { '=', userPassword = password });
+	end
+	return true
+end
+function provider.create_user(username, password) return nil, "Account creation not available with LDAP."; end
 
 function provider.get_sasl_handler()
 	return new_sasl(module.host, {