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!

LDAP Search Help

Status
Not open for further replies.

ronnyjljr

IS-IT--Management
Nov 23, 2003
249
US
Ok, this is my first run at querying ldap.

I am having a difficult time understand how ldap_search works
I connect to the ldap host like this:

Code:
[blue]
echo "Connecting....<br>";
$Connection = ldap_connect($LDAPhost);
echo "Connection result is " . $Connection . "<br/>";

$Bind = ldap_bind($Connection);
echo "Bind result is " . $Bind . "<br/>";
[/blue]

But then the explanation of parametes from php.net does nothing for me in regards to ldap_search.
Could someone please tell me how to do a directory search for a specific username? (uid) and then return the the resulting surname?

Code:
[red]
[green]//I have been trying this [/green]
 $sr=ldap_search($Connection,"uid=test123","sn=*");
  echo "Search result is " . $sr . "<br />";
[/red]

Code:
Results:
Connecting....
Connection result is Resource id #4
Bind result is 1

Warning: ldap_search() [function.ldap-search]: Search: No such object in


I am so confused! Php.net explanations are terrible
Thanks,
Rons

cout << "If you don't know where you want to go, we'll make sure you get taken";
 
No, I do not want to compare anything.
I just want to actually use LDAP to return the information I wanted, given a userid pass back a surname or whatever else I want. I appreciate the help, but I don't really understand the variables used and until I see some solid coding I probably wont.

-Ron

cout << "If you don't know where you want to go, we'll make sure you get taken";
 
the order of service is:
Code:
$LDAPhost = "";//add the host name here
$dn = ""; //ADD THE TREE NAME HERE
$filter = "uid=test123";
$limiters = "sn=*";

$connect = ldap_connect($LDAPhost);
$resultset = ldap_search ($connect, $dn, $filter,$limiters);
$results = ldap_get_entries($connect,$resultset);

//screen dump the results
print_r($results);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top