| Marcin Dobrucki 2005-02-17, 7:52 am |
| Administrateur de systemes wrote:
> I have openldap 2.2.10 on solaris 9 Generic_117171-07 .
> We are just using it as an adressbook .
>
> Is there already a cgi or php script to make some queries to an Ldap
> server to get phone number or email adress trough the web interface . No
> add/modify is needed.
Well, it really depends on your schema, but something like this:
....
$ldap = @ldap_connect("ldap://ldap.yoursite.com");
if (!ldap_bind($ldap)) {
print "LDAP bind failed: " . ldap_error($ldap);
return false;
}
else {
$ldap_search_result =
ldap_search($ldap,$your_ldap_base,"something to search for");
$ldap_entries = ldap_get_entries($ldap,$ldap_search_resu
lt);
...
ldap_close($ldap);
}
....
And your $ldap_entries should now contain whatever the search returned
(as an associative array).
You, ofcourse, need to make sure your php is compiled with LDAP
support enabled.
/Marcin
|