ldap_search and m$ LDAP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rcmn
Forum Newbie
Posts: 21
Joined: Tue Jul 06, 2004 10:35 am

ldap_search and m$ LDAP

Post by rcmn »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

$ldap_host = "ldapserver.com";
   $base_dn = "DC=foo,DC=bar,DC=com";
$filter = "smith";
   
   $connect = ldap_connect($ldap_host);
   $bind = ldap_bind($connect);
   $read = ldap_search($connect, $base_dn,"cn=*$filter*" );
  
   $info = ldap_get_entries($connect, $read);
   echo $info["count"];
and i get the following error
Warning: ldap_search(): Search: Operations error in mypage.php on line 07

Warning: ldap_get_entries(): supplied argument is not a valid ldap result resource in mypage.php on line 09
so it pass the connect and the bind but something is wrong after that.And i tried different things but i keep having errors.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

I've connected with ldap function to AD in a windows environment. It would appear that you are not connected. The trick for me was getting my base dn path right ($base_dn). There's a utility you can use to explore the tree. I can't recall it's name right now. But when you get that right the rest should fall into place for you. Good luck.
rcmn
Forum Newbie
Posts: 21
Joined: Tue Jul 06, 2004 10:35 am

Post by rcmn »

u were right i wasn't connecting i had the error #16.
And that post helped me solve my issues.
Post Reply