replaced getUser function with getEntry function
This commit is contained in:
parent
b1058da8a5
commit
eef73e5ce8
|
@ -117,28 +117,39 @@ class Ldap{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fills the UserEntry object with attributes from the ldap server with the
|
|
||||||
// given dn of an user entry
|
/**
|
||||||
function getUser ($in_user_dn) {
|
* @brief Populates any given object with the available attributes in the
|
||||||
$user = new UserEntry();
|
* LDAP. The names of the member variables of the object must correspond to
|
||||||
$attrs = array();
|
* the attribute names in the LDAP server.
|
||||||
$resource = ldap_read ($this->server,
|
*
|
||||||
$in_user_dn, "(objectClass=*)", $attrs);
|
* @param in_entry_dn distinguished name of entry in ldap
|
||||||
$entry = ldap_first_entry ($this->server, $resource);
|
* @param in_object input object to populate
|
||||||
|
*
|
||||||
|
* @return populated object
|
||||||
|
*/
|
||||||
|
function getEntry ($in_entry_dn, $in_object) {
|
||||||
|
|
||||||
// attributes which are not multivalued ...
|
// read all variables of given object to $vararray
|
||||||
$uid = ldap_get_values ($this->server, $entry, "uid");
|
$vararray = get_object_vars ($in_object);
|
||||||
$user->setUid ($uid[0]);
|
|
||||||
$cn = ldap_get_values ($this->server, $entry, "cn");
|
// set attributefilter only to attributes present in given object
|
||||||
$user->setCn ($cn[0]);
|
$attributefilter = array();
|
||||||
$sn = ldap_get_values ($this->server, $entry, "sn");
|
foreach (array_keys ($vararray) as $varname)
|
||||||
$user->setSn ($sn[0]);
|
$attributefilter[] = $varname;
|
||||||
$givenName = ldap_get_values ($this->server, $entry, "givenName");
|
|
||||||
$user->setGivenName ($givenName[0]);
|
// filter doesn't matter (we only read one entry)
|
||||||
$homeDirectory = ldap_get_values ($this->server, $entry, "homeDirectory");
|
$filter = "(objectClass=*)";
|
||||||
$user->setHomeDirectory ($homeDirectory[0]);
|
$resource = ldap_read ($this->server,
|
||||||
return $user;
|
$in_entry_dn, $filter, $attributefilter);
|
||||||
|
$entry = ldap_first_entry ($this->server, $resource);
|
||||||
|
|
||||||
|
foreach (array_keys ($vararray) as $varname)
|
||||||
|
$in_object->$varname = ldap_get_values ($this->server, $entry, $varname);
|
||||||
|
|
||||||
|
return $in_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// closes connection to server
|
// closes connection to server
|
||||||
function close() {
|
function close() {
|
||||||
|
|
|
@ -54,11 +54,13 @@ echo "</tr>";
|
||||||
foreach ($user_dn_list as $user_dn) {
|
foreach ($user_dn_list as $user_dn) {
|
||||||
echo "<tr>\n";
|
echo "<tr>\n";
|
||||||
|
|
||||||
$userentry = $ldap->getUser ($user_dn);
|
$userentry = new UserEntry();
|
||||||
echo ("<td class=\"userlist\">" . $userentry->getGivenName() . "</td>");
|
$userentry = $ldap->getEntry ($user_dn, $userentry);
|
||||||
echo ("<td class=\"userlist\">" . $userentry->getSn() . "</td>");
|
$ldap->getEntry ($user_dn, $userentry);
|
||||||
echo ("<td class=\"userlist\">" . $userentry->getUid() . "</td>");
|
echo ("<td class=\"userlist\">" . current ($userentry->getGivenName()) . "</td>");
|
||||||
echo ("<td class=\"userlist\">" . $userentry->gethomeDirectory() . "</td>");
|
echo ("<td class=\"userlist\">" . current ($userentry->getSn()) . "</td>");
|
||||||
|
echo ("<td class=\"userlist\">" . current ($userentry->getUid()) . "</td>");
|
||||||
|
echo ("<td class=\"userlist\">" . current ($userentry->gethomeDirectory()) . "</td>");
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
|
|
Loading…
Reference in New Issue