note 107267 added to function.ldap-get-entries

From: Date: Thu, 26 Jan 2012 10:50:10 +0000
Subject: note 107267 added to function.ldap-get-entries
Groups: php.notes 
Request: Send a blank email to php-notes+get-185748@lists.php.net to get a copy of this message
It has been mentioned in the comments below, but the <?php ldap_get_entries($connection,$result) ?> always makes all attributes into lower-case. I found out the hard way that if I'm running an ldap query against the corporate AD and then want to display some results, nothing is actually displayed unless the attribute names area in lower-case. Example: <?php // connect to AD include('ad_con.php'); // limit attributes we want to look for $attributes_ad = array("displayName","description","cn","givenName","sn","mail","co","mobile","company","displayName"); // define base $base =""; // in my script I search based on e-mail, $email variable is passed from the form $result = ldap_search($conn, $base, "mail=$email*", $attributes_ad) or die ("Error in search query"); // put search results into the array ($conn variable is defined in the included 'ad_con.php') $info = ldap_get_entries($conn, $result); //Now, to display the results we want: for ($i=0; $i<$info["count"]; $i++) { // to show the attribute displayName (note the case!) echo $info[$i]["displayname"][0] } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 165.72.200.11 ---- Manual Page -- http://www.php.net/manual/en/function.ldap-get-entries.php Edit -- https://master.php.net/note/edit/107267 Del: integrated -- https://master.php.net/note/delete/107267/integrated Del: useless -- https://master.php.net/note/delete/107267/useless Del: bad code -- https://master.php.net/note/delete/107267/bad+code Del: spam -- https://master.php.net/note/delete/107267/spam Del: non-english -- https://master.php.net/note/delete/107267/non-english Del: in docs -- https://master.php.net/note/delete/107267/in+docs Del: other reasons-- https://master.php.net/note/delete/107267 Reject -- https://master.php.net/note/reject/107267 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#185748) next »