From: hickert Date: Wed, 15 Aug 2007 07:20:25 +0000 (+0000) Subject: Updated password method. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9625233ab14af143b5c20bab6ee8ffc7570a3d64;p=gosa.git Updated password method. keep deactivate status after changing password git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7062 594d385d-05f5-0310-b6e9-bd551577e9d8 --- 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;