Getting only attribute and not its values when doing LDAP calls to 2003 AD server

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi
I followed the examples mentioned in ldap functions pages at
www.php.net<http://www.google.com/url?sa=D&q=www.php.net&usg=AFQjCNHoc0Ba_1Imkk_33DysfxCk38dNag>.

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.
==========================================================
<?php
// 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
Server.");

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

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";
  $filter="sAMAccountName=mkangar";
  $justthese =
array("surname","mail","memberof","name","givenname","sn");
  $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);
  var_dump($info);
  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>
\n";
  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";
    }
   }
  }
 else
  {
  echo "AD bind failed<br>\n";
  }
 ldap_close($resource);
 } // 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
Accounts,DC=gsm1900,DC=org
Number of attributes in 0th entry 0
===================================================

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux