\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; // remove \' from DN string $_GET['DN'] = str_replace("\'", "", $_GET['DN']); // add/remove users if ($_POST['add'] || $_POST['remove']) { // search group and its members $members = array(); $DN = $_GET['DN']; $filter = "(objectClass=posixGroup)"; $attrs = array("memberUID", "cn"); $sr = @ldap_search($_SESSION["ldap"]->server(), $DN, $filter, $attrs); if ($sr) { $grp_info = ldap_get_entries($_SESSION["ldap"]->server, $sr); ldap_free_result($sr); if ($grp_info['count'] != 0) { $members = $grp_info[0]['memberuid']; // delete count entry if ($members) array_shift($members); else $members = array(); } } // add users if ($_POST['add']) { $addmembers = $_POST['users']; if (!$addmembers) $addmembers = array(); if (sizeof($addmembers) > 0) { // search new members for ($i = 0; $i < sizeof($addmembers); $i++) { if (!in_array($addmembers[$i], $members)) $members[] = $addmembers[$i]; } $mod = array(); $mod['memberuid'] = $members; // change LDAP entry if (ldap_modify($_SESSION["ldap"]->server(), $DN, $mod)) { StatusMessage("INFO", _("Added users:"), implode("; ", $addmembers)); } else { StatusMessage("ERROR", _("Unable to add users!"), ""); } } } // remove users if ($_POST['remove']) { $delmembers = $_POST['members']; if (!$delmembers) $delmembers = array(); if (sizeof($delmembers) > 0) { $mod = array(); // search remaining users for ($i = 0; $i < sizeof($members); $i++) { if (!in_array($members[$i], $delmembers)) $mod['memberuid'][] = $members[$i]; } // remove selected users if (sizeof($mod['memberuid']) > 0) { if (ldap_modify($_SESSION["ldap"]->server(), $DN, $mod)) { StatusMessage("INFO", _("Removed users:"), implode("; ", $delmembers)); } else { StatusMessage("ERROR", _("Unable to remove users!"), ""); } } // remove all users else { $mod = array(); $mod['memberuid'] = $delmembers; if (ldap_mod_del($_SESSION["ldap"]->server(), $DN, $mod)) { StatusMessage("INFO", _("Removed users:"), implode("; ", $delmembers)); } else { StatusMessage("ERROR", _("Unable to remove users!"), ""); } } } } } // search group and its members $DN = $_GET['DN']; $filter = "(objectClass=posixGroup)"; $attrs = array("memberUID", "cn"); $sr = @ldap_search($_SESSION["ldap"]->server(), $DN, $filter, $attrs); if ($sr) { $grp_info = ldap_get_entries($_SESSION["ldap"]->server, $sr); ldap_free_result($sr); if ($grp_info["count"] == 0) StatusMessage("WARN", "", _("Unable to find group!")); // use first search result $grp_info = $grp_info[0]; echo "

 

\n"; // title echo "

"; echo _("Edit group members of:") . " " . $grp_info["cn"][0]; echo "

\n"; echo "

 

\n"; echo "
\n"; echo "

\n"; echo "\n"; // table header echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; // group members echo "\n"; // add/remove users echo "\n"; // available users echo "\n"; echo "\n"; echo "
" . _("Group members") . "" . _("Available users") . "
\n"; $members = $grp_info["memberuid"]; if (!$members) $members = array(); array_shift($members); sort($members); echo "\n"; echo "\n"; echo "\n"; echo "

\n"; echo "\" name=\"remove\">\n"; echo "
\n"; // search available users $DN = $_SESSION['config']->get_UserSuffix(); if ($_SESSION['config']->get_samba3() == "yes") { $filter = "(&(objectClass=posixAccount)(objectClass=sambaSamAccount))"; } else $filter = "(&(objectClass=posixAccount)(objectClass=sambaAccount))"; $attrs = array("uid"); $sr = @ldap_search($_SESSION["ldap"]->server(), $DN, $filter, $attrs); if ($sr) { $usr_info = ldap_get_entries($_SESSION["ldap"]->server, $sr); ldap_free_result($sr); // delete count entry array_shift($usr_info); echo "\n"; } // show empty box if no users were found else { echo "\n"; } echo "
\n"; echo "

\n"; echo "
\n"; } else StatusMessage("ERROR", "Unable to find group!", ""); echo ""; echo ""; ?>