Jump to content


Photo

LDAP connecting to Win 2003 AD issue


  • Please log in to reply
2 replies to this topic

#1 pakenney38

pakenney38
  • Members
  • PipPipPip
  • Advanced Member
  • 90 posts

Posted 08 March 2006 - 03:39 PM

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.

#2 pakenney38

pakenney38
  • Members
  • PipPipPip
  • Advanced Member
  • 90 posts

Posted 08 March 2006 - 03:58 PM

Sorry about that. I had to do some "editing" on my post. It was a little too revealing.

#3 pakenney38

pakenney38
  • Members
  • PipPipPip
  • Advanced Member
  • 90 posts

Posted 08 March 2006 - 06:17 PM

I am going to bump this post because I know quite a few people who would like to figure out how PHP and AD are supposed to work together.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users