From 6776d31ceed36b2078a30c18f0b7d1156eca36ef Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Mon, 23 Sep 2013 06:40:25 -0400
Subject: [PATCH] Add new password encodage ('ad') in ldap password drivers (#1489349)

---
 plugins/password/drivers/ldap.php        |    4 ++++
 plugins/password/drivers/ldap_simple.php |    3 +++
 plugins/password/config.inc.php.dist     |    2 +-
 3 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/plugins/password/config.inc.php.dist b/plugins/password/config.inc.php.dist
index bfea529..8c83dd7 100644
--- a/plugins/password/config.inc.php.dist
+++ b/plugins/password/config.inc.php.dist
@@ -201,7 +201,7 @@
 
 // LDAP password hash type
 // Standard LDAP encryption type which must be one of: crypt,
-// ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, or clear.
+// ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, ad or clear.
 // Please note that most encodage types require external libraries
 // to be included in your PHP installation, see function hashPassword in drivers/ldap.php for more info.
 // Default: 'crypt'
diff --git a/plugins/password/drivers/ldap.php b/plugins/password/drivers/ldap.php
index 548d327..29c43fb 100644
--- a/plugins/password/drivers/ldap.php
+++ b/plugins/password/drivers/ldap.php
@@ -279,6 +279,10 @@
             }
             break;
 
+        case 'ad':
+            $cryptedPassword = rcube_charset::convert('"' . $passwordClear . '"', RCUBE_CHARSET, 'UTF-16LE');
+            break;
+
         case 'clear':
         default:
             $cryptedPassword = $passwordClear;
diff --git a/plugins/password/drivers/ldap_simple.php b/plugins/password/drivers/ldap_simple.php
index d47e144..f442d24 100644
--- a/plugins/password/drivers/ldap_simple.php
+++ b/plugins/password/drivers/ldap_simple.php
@@ -247,6 +247,9 @@
                 return false;
             }
             break;
+        case 'ad':
+            $crypted_password = rcube_charset::convert('"' . $password_clear . '"', RCUBE_CHARSET, 'UTF-16LE');
+            break;
         case 'clear':
         default:
             $crypted_password = $password_clear;

--
Gitblit v1.9.1