Changeset

1192:db4085433e5f

mod_auth_ldap: Implement password change
author Kim Alvefur <zash@zash.se>
date Tue, 17 Sep 2013 16:02:33 +0200
parents 1191:1818a7f08580
children 1193:bbe278a56b0a
files mod_auth_ldap/mod_auth_ldap.lua
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
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, {