Diff

mod_auth_ldap/mod_auth_ldap.lua @ 1192:db4085433e5f

mod_auth_ldap: Implement password change
author Kim Alvefur <zash@zash.se>
date Tue, 17 Sep 2013 16:02:33 +0200
parent 1190:c99d8b666eb4
child 1221:3e5f8e844325
line wrap: on
line diff
--- 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, {