X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_password-methods.inc;h=e0b96c0dbafde5719ad5fb740092ca22a1bc5867;hb=c0a9eb78c0756f85fdcff79f4e8c2b847453e2e7;hp=80e8c18b5392cc1d881f13b1bee0b0d2c45cbec3;hpb=1b3fcef1ec46ec349861e3c0e949cdfa9efb2994;p=gosa.git diff --git a/include/class_password-methods.inc b/include/class_password-methods.inc index 80e8c18b5..e0b96c0db 100644 --- a/include/class_password-methods.inc +++ b/include/class_password-methods.inc @@ -109,11 +109,24 @@ function change_password ($dn, $password, $mode=0, $hash= "") $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 != ""){ @@ -159,6 +172,11 @@ function change_password ($dn, $password, $mode=0, $hash= "") $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;