types specify suffix list

This commit is contained in:
Roland Gruber 2011-04-25 17:46:57 +00:00
parent 7a804a6198
commit b66fd35204
2 changed files with 34 additions and 2 deletions

View File

@ -31,7 +31,7 @@ This script is used to display the account profile to the user. <br>
The profile options include the LDAP OU suffix and options provided by
the account modules.<br>
<br>
The values for the OU selection are read with <span style="font-weight: bold;">search_units()</span>.<br>
The values for the OU selection are read with <span style="font-weight: bold;">type->getSuffixList()</span>.<br>
<br>
The <span style="font-style: italic;">account modules</span> provide
all other profile options. The profile editor displays a separate

View File

@ -3,7 +3,7 @@
$Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2005 - 2010 Roland Gruber
Copyright (C) 2005 - 2011 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -130,6 +130,38 @@ class baseType {
return null;
}
/**
* Returns a list of LDAP suffixes for this type.
*
* @return array sorted list of possible suffixes for this type.
*/
public function getSuffixList() {
$suffix = $_SESSION["config"]->get_Suffix(get_class($this));
$ret = array();
$sr = @ldap_search($_SESSION["ldap"]->server(), escapeDN($suffix), "objectClass=organizationalunit", array("DN"), 0, 0, 0, LDAP_DEREF_NEVER);
if ($sr) {
$units = ldap_get_entries($_SESSION["ldap"]->server(), $sr);
$units = cleanLDAPResult($units);
// extract Dns
for ($i = 0; $i < sizeof($units); $i++) {
if ($units[$i]['dn']) $ret[] = $units[$i]['dn'];
}
}
// add root suffix if needed
$found = false;
for ($i = 0; $i < sizeof($ret); $i++) { // search suffix case-intensitive
if (strtolower($suffix) == strtolower($ret[$i])) {
$found = true;
break;
}
}
if (!$found) {
$ret[] = $suffix;
}
usort($ret, 'compareDN');
return $ret;
}
}
?>