index 2755134f11c15115fe7420b9ffada04b9da1afc6..e0b96c0dbafde5719ad5fb740092ca22a1bc5867 100644 (file)
global $config;
$newpass= "";
global $config;
$newpass= "";
+ /* Convert to lower. Methods are lowercase */
+ $hash= strtolower($hash);
+
// Get all available encryption Methods
// NON STATIC CALL :)
// Get all available encryption Methods
// NON STATIC CALL :)
$ldap->cat ($dn, array("shadowLastChange", "userPassword", "uid"));
$attrs = $ldap->fetch ();
$ldap->cat ($dn, array("shadowLastChange", "userPassword", "uid"));
$attrs = $ldap->fetch ();
- // Set encryption type to clear if required
- if (isset($attrs['userPassword'][0]) && preg_match('/^[^{}]+$/', $attrs['userPassword'][0]) && $hash == ""){
- $hash= "clear";
+ // Check if user account was deactivated, indicated by ! after } ... {crypt}!###
+ if(isset($attrs['userPassword'][0]) && preg_match("/^[^\}]*+\}!/",$attrs['userPassword'][0])){
+ $deactivated = TRUE;
+ }else{
+ $deactivated = FALSE;
}
}
+# // Get current password hash method if available
+# if($hash == "" && isset($attrs['userPassword'][0]) && preg_match("/[\{\}]/",$attrs['userPassword'][0])){
+# $hash = preg_replace("/^[^\{]*+\{([^\}]*).*$/","\\1",$attrs['userPassword'][0]);
+# $hash = strtolower($hash);
+# }
+
+# // Set encryption type to clear if required
+# if (!isset($attrs['userPassword'][0]) || $hash == ""){
+# $hash= "clear";
+# }
+
// Detect the encryption Method
if ( (isset($attrs['userPassword'][0]) && preg_match ("/^{([^}]+)}(.+)/", $attrs['userPassword'][0], $matches)) || $hash != ""){
// Detect the encryption Method
if ( (isset($attrs['userPassword'][0]) && preg_match ("/^{([^}]+)}(.+)/", $attrs['userPassword'][0], $matches)) || $hash != ""){
$attrs= generate_smb_nt_hash($password);
}
$attrs= generate_smb_nt_hash($password);
}
+ /* Readd ! if user was deactivated */
+ if($deactivated){
+ $newpass = preg_replace("/(^[^\}]+\})(.*$)/","\\1!\\2",$newpass);
+ }
+
$attrs['userPassword']= array();
$attrs['userPassword']= $newpass;
$attrs['userPassword']= array();
$attrs['userPassword']= $newpass;
-
$ldap->modify($attrs);
$ldap->modify($attrs);
-
+
+ new log("modify","users/passwordMethod",$dn,array_keys($attrs),$ldap->get_error());
if ($ldap->error != 'Success') {
print_red(sprintf(_("Setting the password failed. LDAP server says '%s'."),
if ($ldap->error != 'Success') {
print_red(sprintf(_("Setting the password failed. LDAP server says '%s'."),