Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

no results from ldap query from php

Status
Not open for further replies.

jcaulder

Programmer
Apr 22, 2002
241
US
I have created a basic ldap query and connection using PHP and ldap_connect function. No records are returned from the query.

Here is the sample code:

<?php

$surname = &quot;C&quot;;
$ldaphost = &quot;scorpius&quot;; // your ldap servers
$ldapport = 389; // your ldap server's port number

// Connecting to LDAP
$ds = ldap_connect( $ldaphost, $ldapport )
or die( &quot;Could not connect to {$ldaphost}&quot; );

if ($ds) {
$r = ldap_bind($ds); // this is an &quot;anonymous&quot; bind,

$dn = &quot;DC=sr,DC=org&quot;;
$sr = ldap_search($ds, $dn, &quot;sn=$surname*&quot;);
$info = ldap_get_entries($ds, $sr);
echo $info[&quot;count&quot;];
?>

One of two things happen: a) no records are returned like it is above and the web page stays in a 'loading' state and never returns anything b)if I change the $dn variable slightly, the page does return but with zero records.

I have gone to the Active Directory server and verified all the data is correct. The Base DN exactly matches the value in my php script.

Any ideas on what the problem is? I know it shouldn't be this difficult. Is there anything I can do to diagnose where the problem is?

TIA!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top