Seulement dans ldap_integration-HEAD/: CVS
Seulement dans ldap_integration-HEAD//includes: CVS
diff -ru ldap_integration-HEAD//includes/LDAPInterface.inc ldap_integration/includes/LDAPInterface.inc
--- ldap_integration-HEAD//includes/LDAPInterface.inc	2009-10-27 10:29:18.000000000 -0400
+++ ldap_integration/includes/LDAPInterface.inc	2010-12-02 14:04:59.000000000 -0500
@@ -245,6 +245,15 @@
           ldap_mod_del($this->connection, $dn, array($key => $old_value));
         }
       }
+      //Encodes password for use in Active Directory
+      if ($key == "unicodePwd") {
+         if (is_array($cur_val)) {
+           $this->changeActiveDirectoryPassword($dn, $cur_val[0], $cur_val[1]);
+         }
+         else {
+           $attributes[$key] = $this->encodeActiveDirectoryPassword($cur_val);
+         }
+      }
       if (is_array ($cur_val)) {
         foreach ($cur_val as $mv_key => $mv_cur_val) {
           if ($mv_cur_val == '') {
@@ -257,7 +266,12 @@
       }
     }
 
-    return ldap_modify($this->connection, $dn, $attributes);
+    if (count($attributes) > 0) {
+      return ldap_modify($this->connection, $dn, $attributes);
+    }
+    else {
+      return true;
+    }
   }
 
   function create_entry($dn, $attributes) {
@@ -298,4 +312,51 @@
   static function void_error_handler($p1, $p2, $p3, $p4, $p5) {
     // Do nothing
   }
+
+  function changeActiveDirectoryPassword($dn, $oldpw, $newpw) {
+
+    $oldpw64 = base64_encode($this->encodeActiveDirectoryPassword($oldpw));
+    $newpw64 = base64_encode($this->encodeActiveDirectoryPassword($newpw));
+
+    $ldif=<<<EOT
+dn: $dn
+changetype: modify
+delete: unicodePwd
+unicodePwd:: $oldpw64
+-
+add: unicodePwd
+unicodePwd:: $newpw64
+-
+EOT;
+
+  $cmd = sprintf("/usr/bin/ldapmodify -H %s -D %s -x -W", escapeshellarg($this->server . ':' . $this->port), escapeshellarg($dn));
+
+  if (($fh = popen($cmd, 'w')) === false )
+     die("Open failed: ${php_errormsg}\n");
+
+  fwrite($fh, "$oldpw\n");
+  fwrite($fh, "$ldif\n");
+
+  $status = pclose($fh);
+
+  switch ($status) {
+    case 0:
+      return true;
+      break;
+    case 49:
+      drupal_set_message("Invalid current password.", 'error');
+      break;
+    case 19:
+      drupal_set_message("New password didn't satisfy password policy.", 'error');
+      break;
+  }
+
+  return false;
+
+  }
+
+  function encodeActiveDirectoryPassword($pass) {
+    return mb_convert_encoding('"' . $pass . '"', "UTF-16LE");
+  }
+
 }
diff -ru ldap_integration-HEAD//ldapauth.module ldap_integration/ldapauth.module
--- ldap_integration-HEAD//ldapauth.module	2010-10-13 07:03:26.000000000 -0400
+++ ldap_integration/ldapauth.module	2010-12-02 14:03:00.000000000 -0500
@@ -211,13 +211,19 @@
     case 'user_profile_form':
       $account = $form["_account"]["#value"];
       if ($user->uid != 1 && isset($account->ldap_authentified)) {
-        if (LDAPAUTH_DISABLE_PASS_CHANGE)
-        unset($form['account']['pass']);
+        if (LDAPAUTH_DISABLE_PASS_CHANGE) {
+          unset($form['account']['pass']);
+        }
+        else {
+          // Add current password field for AD
+          if (!user_access('administer users')) {
+            $form['account']['currentpass'] = array('#type' => 'password', '#size' => 25, '#weight' => -1, '#title' => t('Current password'));
+          }
+        }
 
         switch (LDAPAUTH_ALTER_EMAIL_FIELD) {
           case LDAPAUTH_EMAIL_FIELD_REMOVE :
-            $form['account']['mail']['#type'] = 'hidden';
-            $form['account']['mail']['#attributes']['READONLY'] = 'READONLY';
+            $form['account']['mail']['#access'] = FALSE;
             break;
           case LDAPAUTH_EMAIL_FIELD_DISABLE :
             $form['account']['mail']['#attributes']['READONLY'] = 'READONLY';
@@ -229,7 +235,7 @@
           $form['mail'] = $form['account']['mail'];
           unset($form['account']);
         }
-      }
+     }
       break;
   }
 }
diff -ru ldap_integration-HEAD//ldapdata.module ldap_integration/ldapdata.module
--- ldap_integration-HEAD//ldapdata.module	2009-10-27 10:29:17.000000000 -0400
+++ ldap_integration/ldapdata.module	2010-12-02 14:03:44.000000000 -0500
@@ -402,7 +402,7 @@
         if ($key == 'pass') {
           if ($value) {
             $pw = $_ldapdata_ldap->getOption('encrypted') ? '{md5}'. base64_encode(pack('H*', md5($value))) : $value;
-            $writeout[$ldap_attr] = $pw;
+            (empty($edit['currentpass'])) ? ($writeout[$ldap_attr] = $pw) : ($writeout[$ldap_attr] = array($edit['currentpass'],$pw));
           }
         }
         else {
