Code

Updated userManagement to use the new passwordMethods lock_account/unlock_account
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 27 Nov 2008 08:57:58 +0000 (08:57 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 27 Nov 2008 08:57:58 +0000 (08:57 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13052 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/admin/users/class_userManagement.inc

index 6d2e83c9e4aefc98c877a86c25c6c1fbc6d4eb5b..945f60ebd1ef8bba055d45eac173d675bbf5cd11 100644 (file)
@@ -647,45 +647,24 @@ class userManagement extends plugin
 
       /* Get entry check current status */
       $val = $this->list[$s_entry];
-      $pwd = $val['userPassword'][0];
-
-
       if (!preg_match("/w/",$this->ui->get_permissions($val['dn'],"users/password"))){
-
-        /* Missing permissions, show message */
-        msg_dialog::display(_("Password change"),_("You have no permission to change the lock status for this user!"),WARNING_DIALOG);
-
+        msg_dialog::display(_("Password change"),
+            _("You have no permission to change the lock status for this user!"),WARNING_DIALOG);
       }else{
-
-        if(!preg_match("/^\{[^\}]/",$pwd)){
-          trigger_error("Can not deactivate user which is using clear password encryption.");
-        }else{
-
-          $locked = false;
-          if(preg_match("/^[^\}]*+\}!/",$pwd)){
-            $locked = true;
-          }
-
-          /* Create ldap array to update status */
-          $attrs = array("userPassword" => $pwd);
-          if($locked){
-            $attrs['userPassword'] = preg_replace("/(^[^\}]+\})!(.*$)/","\\1\\2",$attrs['userPassword']);
+        $pwd = $val['userPassword'][0];
+        $method = passwordMethod::get_method($pwd,$val['dn']);
+        if($method instanceOf passwordMethod){
+          if($method->is_locked($this->config,$val['dn'])){
+            $method->unlock_account($this->config,$val['dn']);
           }else{
-            $attrs['userPassword'] = preg_replace("/(^[^\}]+\})(.*$)/","\\1!\\2",$attrs['userPassword']);
-          }
-
-          /* Write new status back to ldap */
-          $ldap = $this->config->get_ldap_link();
-          $ldap->cd($val['dn']);
-          $ldap->modify($attrs);
-          if (!$ldap->success()){
-            msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $val['dn'], 0, get_class()));
+            $method->lock_account($this->config,$val['dn']);
           }
+        }else{
+          // Can't lock unknown methods.
         }
       }
     }
 
-
     /********************
       Delete entry Canceled 
      ********************/