Hi Sven, I have tried to put the my login username in that place. But it showed "Invalid Credental". Since I am new to this AD and LDAP, would it be the format of my username? Should I just put my login username, or should I put the whole bunch of line such as "CN=my name, DN=xxxx" something like this? I really confuse the login format of this and so does "objectClass" stuff for filter. Could you give me an idea? Do you know any web site that talk about this ? Thank you very much! Vince "Sven" <svenie@gmx.li> wrote in message 20030703104334.40515.qmail@pb1.pair.com">news:20030703104334.40515.qmail@pb1.pair.com... > hi vince, > > Vince C wrote: > > <?php > > $ldaphost= "company.com"; > > > > if(!($ldap = ldap_connect($ldaphost,389))){ > > die("ldap server cannot be reached"); > > } else { > > $oudc = " dc=company, dc=com"; > > $dn2 = ""; > > $password = ""; > > did you define your user and password? afaik win ad isn't searchable by > anonymous. > ciao SVEN > > > echo "<p>Connected and ready to bind..."; > > if (!($res = @ldap_bind($ldap, $dn2, $password))) { > > print(ldap_error($ldap) . "<BR>"); > > die ("Could not bind the $dn2"); > > echo "<p>Couldn't bind ...."; > > } else { > > echo "<p>Binded and Ready to search...."; > > echo "<br>LDAP = $ldap"; > > echo "<br>oudc = $oudc"; > > > > // > > $filter="(&(objectClass=user)(objectCategory=person)(|(sn=sorg)))"; > > $filter= "sn=*"; $sr=ldap_search($ldap,$oudc,$filter); > > echo "<p>number of entries found: " . ldap_count_entries($ldap, > > $sr) . "<p>"; > > echo "<br>filter = $filter"; > > echo "<br>sr=$sr"; > > > > if (!$sr) { > > die("<p>search failed\n"); > > } else { > > echo "<p> Searched and ready for get entries....."; > > $info= ldap_get_entries($ldap, $sr); > > > > for ($i=0; $i<$info["count"]; $i++) { > > print ("<TR>"); > > print ("<TD width=15%>" . $info[$i]["cn"][0] . " " . > > $info[$i]["sn"][0] . "</TD>"); > > print ("<TD width=85%>" . $info[$i]["mail"][0] . "</TD>"); > > print ("</TR>"); > > print "<br>In the display FOR loop"; > > } > > echo "<br> After loop....."; > > } > > } > > ldap_unbind($ldap); > > echo "<p>LDAP unbinded...."; > > } > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php