moved suffix search to ldap.inc

removed unneeded echo in profilecreate.php
This commit is contained in:
Roland Gruber 2003-06-14 12:16:59 +00:00
parent d12c962abc
commit e4b5049df9
4 changed files with 20 additions and 29 deletions

View File

@ -132,6 +132,23 @@ class Ldap{
} }
} }
// returns an array with all organizational units under the given suffix
function search_units($suffix) {
$sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, "objectClass=organizationalunit", array("DN"));
if ($sr) {
$units = ldap_get_entries($_SESSION["ldap"]->server, $sr);
// delete first array entry which is "count"
array_shift($units);
// remove sub arrays
for ($i = 0; $i < sizeof($units); $i++) $units[$i] = $units[$i]['dn'];
// add root suffix if needed
if (!in_array($suffix, $units)) {
array_push($units, $suffix);
}
}
return $units;
}
// returns the LDAP connection handle // returns the LDAP connection handle
function server() { function server() {
return $this->server; return $this->server;

View File

@ -231,20 +231,7 @@ echo ("<br>\n");
if (! $_GET['norefresh']) { if (! $_GET['norefresh']) {
// generate list of possible suffixes // generate list of possible suffixes
$sr = @ldap_search($_SESSION["ldap"]->server(), $grp_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_GroupSuffix());
$_SESSION["config"]->get_GroupSuffix(),
"objectClass=organizationalunit", array("DN"));
if ($sr) {
$grp_units = ldap_get_entries($_SESSION["ldap"]->server, $sr);
// delete first array entry which is "count"
array_shift($grp_units);
// remove sub arrays
for ($i = 0; $i < sizeof($grp_units); $i++) $grp_units[$i] = $grp_units[$i]['dn'];
// add root suffix from config
if (!in_array($_SESSION["config"]->get_GroupSuffix(), $grp_units)) {
array_push($grp_units, $_SESSION["config"]->get_GroupSuffix());
}
}
} }
echo ("<p align=\"left\">\n"); echo ("<p align=\"left\">\n");

View File

@ -225,20 +225,7 @@ echo ("<br>\n");
if (! $_GET['norefresh']) { if (! $_GET['norefresh']) {
// generate list of possible suffixes // generate list of possible suffixes
$sr = @ldap_search($_SESSION["ldap"]->server(), $hst_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_HostSuffix());
$_SESSION["config"]->get_HostSuffix(),
"objectClass=organizationalunit", array("DN"));
if ($sr) {
$hst_units = ldap_get_entries($_SESSION["ldap"]->server, $sr);
// delete first array entry which is "count"
array_shift($hst_units);
// remove sub arrays
for ($i = 0; $i < sizeof($hst_units); $i++) $hst_units[$i] = $hst_units[$i]['dn'];
// add root suffix from config
if (!in_array($_SESSION["config"]->get_HostSuffix(), $hst_units)) {
array_push($hst_units, $_SESSION["config"]->get_HostSuffix());
}
}
} }
echo ("<p align=\"left\">\n"); echo ("<p align=\"left\">\n");

View File

@ -274,7 +274,7 @@ elseif ($_GET['type'] == "host") {
} }
// error: no or wrong type // error: no or wrong type
else echo (StatusMessage("ERROR", "", _("No type specified!"))); else StatusMessage("ERROR", "", _("No type specified!"));
echo ("</body></html>\n"); echo ("</body></html>\n");