diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc
index 7d2fd5cda6cd0ad5aa561c4c2d9f4ce0d2251b3f..bcf05f4aca6a44941124b866700c68d61f579041 100644 (file)
/* Creat dialog object */
$this->DivListUsers = new divListUsers($this->config,$this);
- /* LOCK MESSAGE Vars */
- $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/");
}
/* Call parent execute */
plugin::execute();
+ /* LOCK MESSAGE Vars */
+ $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/");
+
$smarty = get_smarty(); // Smarty instance
$s_action = ""; // Contains the action to be taken
$s_entry = ""; // The value for s_action
foreach(array("del" => "user_del", "edit" => "user_edit",
"new" => "user_new",
"new_tpl" => "user_tplnew",
+ "create_user_from_tpl" => "userfrom_tpl",
"change_pw" => "user_chgpw",
"editPaste" => "editPaste", "copy" => "copy",
- "cut" => "cut") as $act => $name){
+ "cut" => "cut",
+ "toggle_lock_status" => "toggle_lock_status" ) as $act => $name){
if (preg_match("/".$name.".*/", $key)){
$s_action= $act;
$s_tab= "user";
}
- /* Display the copy & paste dialog, if it is currently open */
- $ret = $this->copyPasteHandling($s_action,$s_entry);
- if($ret){
- return($ret);
+ /* Some may be active but diabled in gosa.conf. */
+ if(!search_config($this->config->data['TABS'], $s_tab , "CLASS")){
+ $s_tab = "user";
+ }
+
+ /* Get 'dn' from posted 'uid' */
+ if(in_array_ics($s_action,array("editPaste","cut","copy")) || ($this->CopyPasteHandler && $this->CopyPasteHandler->stillOpen())){
+
+ if(isset($this->list[trim($s_entry)]['dn'])){
+ $dn= $this->list[trim($s_entry)]['dn'];
+ }else{
+ $dn = $this->DivListUsers->selectedBase;
+ }
+
+ $acl= get_permissions ($dn, $this->ui->subtreeACL);
+ $acl= get_module_permission($acl, "user", $dn);
+
+ if($acl != "#all#"){
+ print_red (_("You are not allowed to execute this method!"));
+ }else{
+ /* Display the copy & paste dialog, if it is currently open */
+ $ret = $this->copyPasteHandling($s_action,$s_entry);
+ if($ret){
+ return($ret);
+ }
+ }
+ }
+
+
+ /********************
+ Toggle lock status for user
+ ********************/
+
+ if($s_action == "toggle_lock_status" && isset($this->list[$s_entry])){
+
+ /* Get entry check current status */
+ $val = $this->list[$s_entry];
+ $pwd = $val['userPassword'][0];
+
+ 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']);
+ }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($locked){
+ show_ldap_error($ldap->get_error(),_("Could not set user status from locked to unlocked."));
+ }else{
+ show_ldap_error($ldap->get_error(),_("Could not set user status from unlocked to locked."));
+ }
+ }
}
********************/
/* Continue template editing */
- if ((isset($_POST['template_continue']) && $_POST['template'] != 'none' && !isset($_POST['uid']))){
+ if ((isset($_POST['template_continue'])) && ($_POST['template'] != 'none') && (!isset($_POST['uid']))){
$this->sn = $_POST['sn'];
$this->givenName = $_POST['givenName'];
$ldap= $this->config->get_ldap_link(TRUE);
if ($SubSearch){
$ListTemp = get_list($filter, $this->ui->subtreeACL, $base,
- array("uid", "givenName", "sn", "objectClass"), GL_SUBSEARCH | GL_SIZELIMIT);
+ array("uid", "givenName", "sn", "objectClass","userPassword"), GL_SUBSEARCH | GL_SIZELIMIT);
} else {
$base= get_people_ou().$base;
$ListTemp = get_list($filter, $this->ui->subtreeACL, $base,
- array("uid", "givenName", "sn", "objectClass"), GL_SIZELIMIT);
+ array("uid", "givenName", "sn", "objectClass","userPassword"), GL_SIZELIMIT);
}
$SortTemp = array();
+ $List = array();
foreach($ListTemp as $Key => $Entry){
- // Generate caption for rows
- if (isset($Entry["sn"]) && isset($Entry["givenName"])){
- $display= $Entry["sn"][0].", ".$Entry["givenName"][0]." [".$Entry["uid"][0]."]";
- } else {
- $display= "[".$Entry["uid"][0]."]";
- }
- $SortTemp[$Key] = $display;
+ /* Skip entries that are not located under the people ou (normaly 'ou=people,')
+ * Else winstations will be listed too, if you use the subtree flag.
+ */
+ if(!preg_match("/".normalizePreg(get_people_ou())."/i",$Entry['dn'])){
+ continue;
+ }else{
+
+ // Generate caption for rows
+ if (isset($Entry["sn"]) && isset($Entry["givenName"])){
+ $display= $Entry["sn"][0].", ".$Entry["givenName"][0]." [".$Entry["uid"][0]."]";
+ } else {
+ $display= "[".$Entry["uid"][0]."]";
+ }
+
+ $display = strtolower($display);
+ $List[$display] = $Entry;
+ $SortTemp[$display] = $display;
+ }
}
natcasesort($SortTemp);
reset($SortTemp);
- foreach($SortTemp as $Key => $Value){
- $this->list[] = $ListTemp[$Key];
+
+ $this->list = array();
+ foreach($SortTemp as $Key){
+ $this->list[] = $List[$Key];
}
}
/* Use the last dn to search for it's ID in the newly generated list. */
$dn= $this->CopyPasteHandler->lastdn;
+
+ /* Get new user list */
+ $this->reload();
foreach($this->list as $id => $entry){
if($entry['dn'] == $dn){
$s_entry= $id;
function save_object()
{
/* Handle divlist filter && department selection*/
- $this->DivListUsers->save_object();
+ if(!is_object($this->usertab)){
+ $this->DivListUsers->save_object();
+ }
}
/* A set of disabled and therefore overloaded functions. They are