X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_password-methods.inc;h=e0b96c0dbafde5719ad5fb740092ca22a1bc5867;hb=1352a55239650c688be5bffa60230dc15d9983af;hp=2755134f11c15115fe7420b9ffada04b9da1afc6;hpb=38e112e6bdb6281beace80e8e29f2a3d2b0ca490;p=gosa.git diff --git a/include/class_password-methods.inc b/include/class_password-methods.inc index 2755134f1..e0b96c0db 100644 --- a/include/class_password-methods.inc +++ b/include/class_password-methods.inc @@ -95,6 +95,9 @@ function change_password ($dn, $password, $mode=0, $hash= "") global $config; $newpass= ""; + /* Convert to lower. Methods are lowercase */ + $hash= strtolower($hash); + // Get all available encryption Methods // NON STATIC CALL :) @@ -106,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 != ""){ @@ -156,12 +172,17 @@ 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; - $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'."),