Jump to content

LDAP connecting to Win 2003 AD issue


pakenney38

Recommended Posts

So here is the offending code:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?PHP
$ldaprdn = 'USR@domain.net';
$ldappass = 'PWD';
$ds = 'server.domain.net';
$dn = 'dc=domain,dc=net';
$ldapport = 389;
$ldapconn = ldap_connect($ds, $ldapport)
or die("Could not connect to LDAP server.");

if ($ldapconn)
{
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
if ($ldapbind)
{
echo "LDAP bind successful...";


$filter = "'cn=*Kenney*'";
$fields = array("ou", "mail");
$sr = ldap_search($ds, $dn, $filter, $fields);

$info = ldap_get_entries($ds, $sr);

for ($i=0; $i<$info["count"]; $i++)
{
echo "<br>";
echo "ou: " . $info[$i]["ou"][0];
echo "mail: " . $info[$i]["mail"][0];
}

}
else
{
echo "LDAP bind failed...";
}
}
ldap_close($ldapconn);
?>
[/quote]

Here is the result:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]LDAP bind successful...
Warning: ldap_search(): supplied argument is not a valid ldap link resource in e:\intertest\test.php on line 20

Warning: ldap_get_entries(): supplied argument is not a valid ldap link resource in e:\intertest\test.php on line 22
[/quote]

I know I'm just misusing the ldap_search() function or something, so please, someone set me straight here.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.