Commit aa0672e2ad04009b6792a6baa86e70cca342a339

Authored by Michael Joseph
1 parent 7b203fce

added custom attributes to getUsers ldap search method


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@80 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 10 additions and 11 deletions
lib/class.AuthLdap.php
... ... @@ -329,26 +329,26 @@ class AuthLdap {
329 329  
330 330 // 2.5 User methods ----------------------------------------------------------
331 331  
332   - function getUsers( $search) {
  332 + function getUsers( $search, $attributeArray) {
333 333 /* 2.5.1 : Returns an array containing a details of users, sorted by
334 334 ** username. The search criteria is a standard LDAP query - * returns all
335   - ** users.
  335 + ** users. The $attributeArray variable contains the required user detail field names
336 336 */
337 337  
338   - $checkDn = "ou=" .$this->people. ", " .$this->dn;
339   - echo $checkDn;
  338 + // builds the appropriate dn, based on whether $this->people and/or $this->group is set
  339 + $checkDn = $this->setDn( true);
  340 +
340 341 // Perform the search and get the entry handles
341 342 $this->result = ldap_search( $this->connection, $checkDn, "uid=" .$search);
342 343 $info = ldap_get_entries( $this->connection, $this->result);
343 344 for( $i = 0; $i < $info["count"]; $i++){
344 345 // Get the username, and create an array indexed by it...
345 346 // Modify these as you see fit.
346   - $uname = $info[$i]["uid"][0];
347   - $userslist["$uname"]["cn"] = $info[$i]["cn"][0];
348   - $userslist["$uname"]["mail"] = $info[$i]["mail"][0];
349   - $userslist["$uname"]["phone"] = $info[$i]["telephonenumber"][0];
350   - $userslist["$uname"]["job"] = $info[$i]["employeetype"][0];
351   - $userslist["$uname"]["entryid"] = $info[$i]["entryid"][0];
  347 + $uname = $info[$i]["uid"][0];
  348 + // add to the array for each attribute in my list
  349 + for ( $i = 0; $i < count( $attributeArray); $i++) {
  350 + $userslist["$uname"]["$attributeArray[$i]"] = $info[$i][strtolower($attributeArra[$i])][0];
  351 + }
352 352 }
353 353  
354 354 if ( !@asort( $userslist)) {
... ... @@ -362,7 +362,6 @@ class AuthLdap {
362 362 return $userslist;
363 363 }
364 364  
365   -
366 365 } // End of class
367 366  
368 367  
... ...