From aa0672e2ad04009b6792a6baa86e70cca342a339 Mon Sep 17 00:00:00 2001 From: Michael Joseph Date: Thu, 9 Jan 2003 12:41:15 +0000 Subject: [PATCH] added custom attributes to getUsers ldap search method --- lib/class.AuthLdap.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/class.AuthLdap.php b/lib/class.AuthLdap.php index 237d48b..42d8b91 100644 --- a/lib/class.AuthLdap.php +++ b/lib/class.AuthLdap.php @@ -329,26 +329,26 @@ class AuthLdap { // 2.5 User methods ---------------------------------------------------------- - function getUsers( $search) { + function getUsers( $search, $attributeArray) { /* 2.5.1 : Returns an array containing a details of users, sorted by ** username. The search criteria is a standard LDAP query - * returns all - ** users. + ** users. The $attributeArray variable contains the required user detail field names */ - $checkDn = "ou=" .$this->people. ", " .$this->dn; - echo $checkDn; + // builds the appropriate dn, based on whether $this->people and/or $this->group is set + $checkDn = $this->setDn( true); + // Perform the search and get the entry handles $this->result = ldap_search( $this->connection, $checkDn, "uid=" .$search); $info = ldap_get_entries( $this->connection, $this->result); for( $i = 0; $i < $info["count"]; $i++){ // Get the username, and create an array indexed by it... // Modify these as you see fit. - $uname = $info[$i]["uid"][0]; - $userslist["$uname"]["cn"] = $info[$i]["cn"][0]; - $userslist["$uname"]["mail"] = $info[$i]["mail"][0]; - $userslist["$uname"]["phone"] = $info[$i]["telephonenumber"][0]; - $userslist["$uname"]["job"] = $info[$i]["employeetype"][0]; - $userslist["$uname"]["entryid"] = $info[$i]["entryid"][0]; + $uname = $info[$i]["uid"][0]; + // add to the array for each attribute in my list + for ( $i = 0; $i < count( $attributeArray); $i++) { + $userslist["$uname"]["$attributeArray[$i]"] = $info[$i][strtolower($attributeArra[$i])][0]; + } } if ( !@asort( $userslist)) { @@ -362,7 +362,6 @@ class AuthLdap { return $userslist; } - } // End of class -- libgit2 0.21.4