note 94245 added to function.ldap-search

From: Date: Sun, 25 Oct 2009 06:35:26 +0000
Subject: note 94245 added to function.ldap-search
Groups: php.notes 
Request: Send a blank email to php-notes+get-162040@lists.php.net to get a copy of this message
This function accepts LDAP search results and return a flat table (2-d array) with search results. <?php /* * This function returns flat table out of search results * $ad - a valid connection to Active Directory (returned by ldap_connect) * $sr - a search result (returned by ldap_search) * $key- an attribute name to be used as the key in the resulting array * Returns 2-d array as the following: * return_value["keyfieldvalue"]["attributename"] = "attribute value"; // entries with key filed present * return_value[i]["attributename"] = "attribute value"; // entries with key fields missing */ function ldap_flatresults($ad,$sr,$key=false) { for ($entry=ldap_first_entry($ad,$sr); $entry!=false; $entry=ldap_next_entry($ad,$entry)) { $user = array(); $attributes = ldap_get_attributes($ad,$entry); for($i=$attributes['count'];$i-- >0;) { $user[strtolower($attributes[$i])] = $attributes[$attributes[$i]][0]; } if( $key && $user[$key] ) $users[strtolower($user[$key])] = $user; else $users[] = $user; } return $users; } ?> ---- Server IP: 213.186.192.247 Probable Submitter: 94.27.68.109 ---- Manual Page -- http://www.php.net/manual/en/function.ldap-search.php Edit -- https://master.php.net/note/edit/94245 Del: integrated -- https://master.php.net/note/delete/94245/integrated Del: useless -- https://master.php.net/note/delete/94245/useless Del: bad code -- https://master.php.net/note/delete/94245/bad+code Del: spam -- https://master.php.net/note/delete/94245/spam Del: non-english -- https://master.php.net/note/delete/94245/non-english Del: in docs -- https://master.php.net/note/delete/94245/in+docs Del: other reasons-- https://master.php.net/note/delete/94245 Reject -- https://master.php.net/note/reject/94245 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#162040) next »