From 793e24885b0e210c630be8a1db78e0e795c33c47 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 31 Jul 2009 02:36:39 -0400
Subject: [PATCH] - Password plugin: added ldap_force_replace option (#1486014)

---
 plugins/password/drivers/ldap.php    |    2 +-
 plugins/password/config.inc.php.dist |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/plugins/password/config.inc.php.dist b/plugins/password/config.inc.php.dist
index 7bcd31b..abe2749 100644
--- a/plugins/password/config.inc.php.dist
+++ b/plugins/password/config.inc.php.dist
@@ -105,4 +105,10 @@
 // Default: 'userPassword'
 $rcmail_config['password_ldap_pwattr'] = 'userPassword';
 
+// LDAP password force replace
+// Force LDAP replace in cases where ACL allows only replace not read
+// See http://pear.php.net/package/Net_LDAP2/docs/latest/Net_LDAP2/Net_LDAP2_Entry.html#methodreplace
+// Default: true
+$rcmail_config['password_ldap_force_replace'] = true;
+
 ?>
diff --git a/plugins/password/drivers/ldap.php b/plugins/password/drivers/ldap.php
index 7e92ea5..1087826 100644
--- a/plugins/password/drivers/ldap.php
+++ b/plugins/password/drivers/ldap.php
@@ -54,7 +54,7 @@
     // Writing new crypted password to LDAP
     $userEntry = $ldap->getEntry($userDN);
     if (Net_LDAP2::isError($userEntry)) {return PASSWORD_CONNECT_ERROR;}
-    if (!$userEntry->replace(array($rcmail->config->get('password_ldap_pwattr') => $newCryptedPassword))) {return PASSWORD_CONNECT_ERROR;}
+    if (!$userEntry->replace(array($rcmail->config->get('password_ldap_pwattr') => $newCryptedPassword),$rcmail->config->get('password_ldap_force_replace'))) {return PASSWORD_CONNECT_ERROR;}
     if (Net_LDAP2::isError($userEntry->update())) {return PASSWORD_CONNECT_ERROR;}
     
     // All done, no error

--
Gitblit v1.9.1