I followed the examples mentioned in ldap functions pages at

But I am getting only the attribute names and not the values stored in
attributes array. Can some one give me some tips to fix my issue.
Here is my configuration.

Apache/2.0.59 HP-UX_Apache-based_Web_Server (Unix) DAV/2 PHP/5.2.13
on  HP-UX 11.11 and php is using OpenLDAP, vendor version 20122

Here is my php code.
// First program written for testing Microsoft AD Authentication
// Written by Madhu Kangara on 07/16/2010

$host = "secldapwest.gsm1900.org";
$myLogin = "gsm1900\\mkangar";
$myPass = "password_here";
$resource = ldap_connect($host) or die("Could not connect to AD

// PHP will connect to server on the port 389
// Then you have to authenticate with an AD user to access to his

if ($resource)
 //Authentication to the AD with a windows login, password
 //$bind = ldap_bind($resource, $myLogin."@".$host, $myPass);
 // binding to AD server
 $bind = ldap_bind($resource, $myLogin, $myPass);

 // verify binding
 if ($bind)
  echo "AD bind successful<br>\n";
  //$dn contain information asked by Windows server to browse the
correct AD tree.
  $dn ="OU=User Accounts,DC=gsm1900,DC=org";
  $justthese =
  $sizelimit=15; // limit to maximum 15 return rows
  $result = ldap_search($resource,$dn,$filter,$justthese,$sizelimit);
  $result = ldap_search($resource,$dn,$filter,$justthese);
  $info = ldap_get_entries($resource, $result);
  echo "<br>\n";
  echo $info["count"]. " entries returned<br>\n";
  echo "first surname entry " . $info[0]["surname"][0]. "<br>\n";
  echo "first mail entry " . $info[0]["mail"][0]. "<br>\n";
  echo "first memberof entry " . $info[0]["memberof"][0]. "<br>\n";
  echo "first name entry " . $info[0]["name"][0]. "<br>\n";
  echo "first givenname entry " . $info[0]["givenname"][0]. "<br>\n";
  echo "first sn entry " . $info[0]["sn"][0]. "<br>\n";
  echo "DN: " . $info[0]["dn"]. "<br>\n";
  echo "Number of attributes in 0th entry " . $info[0]["count"]. " <br>
  for ($i=0; $i<$info["count"];$i++)
   for ($j=0;$j<$info[$i]["count"];$j++)
    echo $info[$i][$j].": ".$info[$i][$info[$i][$j]][0]."\n";
  echo "AD bind failed<br>\n";
 } // end of if ($resource)
Here is the output from webpage. You can see that it is not displaying the
values. What am I doing wrong. Do I need to perform any configuration
settings in ldap.conf file at my side?
AD bind successful
array(2) { ["count"]=> int(1) [0]=> array(2) { ["count"]=> int(0)
["dn"]=> string(93) "CN=MKangar,OU=Data Center Ops,OU=Systems
Operations,OU=COS,OU=User Accounts,DC=gsm1900,DC=org" } }
1 entries returned
first surname entry
first mail entry
first memberof entry
first name entry
first givenname entry
first sn entry
DN: CN=MKangar,OU=Data Center Ops,OU=Systems Operations,OU=COS,OU=User
Number of attributes in 0th entry 0

Reply via email to