Code

Updated functions.inc - change_password
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 27 Nov 2008 09:01:41 +0000 (09:01 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 27 Nov 2008 09:01:41 +0000 (09:01 +0000)
-Keep entries locked

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13053 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/functions.inc

index 991f63e3e427b5c3380927988f3f3f0d1cc080a5..efed58c996b1e672bdc6aba08d0635ea8500caf2 100644 (file)
@@ -2468,13 +2468,6 @@ function change_password ($dn, $password, $mode=0, $hash= "")
   $ldap->cat ($dn, array("shadowLastChange", "userPassword", "uid"));
   $attrs      = $ldap->fetch ();
 
-  // 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;
-  }
-
   /* Is ensure that clear passwords will stay clear */
   if($hash == "" && isset($attrs['userPassword'][0]) && !preg_match ("/^{([^}]+)}(.+)/", $attrs['userPassword'][0])){
     $hash = "clear";
@@ -2502,6 +2495,8 @@ function change_password ($dn, $password, $mode=0, $hash= "")
 
   if($test instanceOf passwordMethod){
 
+    $deactivated = $test->is_locked($config,$dn);
+
     /* Feed password backends with information */
     $test->dn= $dn;
     $test->attrs= $attrs;
@@ -2529,16 +2524,16 @@ function change_password ($dn, $password, $mode=0, $hash= "")
       $attrs= generate_smb_nt_hash($password);
     }
 
-    /* Read ! if user was deactivated */
-    if($deactivated){
-      $newpass = preg_replace("/(^[^\}]+\})(.*$)/","\\1!\\2",$newpass);
-    }
-
     $attrs['userPassword']= array();
     $attrs['userPassword']= $newpass;
 
     $ldap->modify($attrs);
 
+    /* Read ! if user was deactivated */
+    if($deactivated){
+      $test->lock_account($config,$dn);
+    }
+
     new log("modify","users/passwordMethod",$dn,array_keys($attrs),$ldap->get_error());
 
     if (!$ldap->success()) {