From: hickert Date: Mon, 26 Oct 2009 13:29:16 +0000 (+0000) Subject: Added entry locking / unlocking X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3b56d94349fb588fe61ee0147d18caad1d824c9a;p=gosa.git Added entry locking / unlocking git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14639 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/admin/users/class_userManagement.inc b/gosa-core/plugins/admin/users/class_userManagement.inc index 502dd2c6b..fa8d623fb 100644 --- a/gosa-core/plugins/admin/users/class_userManagement.inc +++ b/gosa-core/plugins/admin/users/class_userManagement.inc @@ -64,12 +64,59 @@ class userManagement extends management $this->registerAction("cut", "copyPasteHandler"); $this->registerAction("paste", "copyPasteHandler"); - $this->registerAction("lock", "alert"); - $this->registerAction("unlock", "alert"); + $this->registerAction("lock", "lockEntry"); + $this->registerAction("unlock", "alert"); $this->registerAction("new_template", "newTemplate"); } + + function lockEntry($action,$entry) + { + $disallowed = array(); + $dns = array(); + foreach($entry as $dn){ + if (!preg_match("/w/",$this->ui->get_permissions($dn,"users/password"))){ + $disallowed[] = $dn; + }else{ + $allowed[] = $dn; + } + } + if(count($disallowed)){ + msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG); + } + $ldap = $this->config->get_ldap_link(); + foreach($allowed as $dn){ + $ldap->cat($dn, array('userPassword')); + if($ldap->count() == 1){ + $val = $ldap->fetch(); + $pwd = $val['userPassword'][0]; + $method = passwordMethod::get_method($pwd,$val['dn']); + $success= false; + if($method instanceOf passwordMethod){ + if($method->is_locked($this->config,$val['dn'])){ + $success= $method->unlock_account($this->config,$val['dn']); + }else{ + $success= $method->lock_account($this->config,$val['dn']); + } + + /* Check for success */ + if (!$success){ + $hn= $method->get_hash_name(); + if (is_array($hn)){ + $hn= $hn[0]; + } + msg_dialog::display(_("Account locking"), + sprintf(_("Password method '%s' does not support locking. Account has not been locked!"), $hn),WARNING_DIALOG); + } + }else{ + // Can't lock unknown methods. + } + } + } + } + + function alert($action,$values) { print_a(array($action,$values));