|
Posted by Steve JORDI on 01/10/07 13:50
Hi,
I'm checking a user identity on a secure LDAP server using the
following code:
$ldapconn = ldap_connect("ldaps://myserver.mycompany.ch", 636 )
or die( "Can't connect to LDAP" ) ;
$ldapresult = ldap_search( $ldapconn,"o=mycompany,c=ch","cn=".$name);
if( $ldapresult ) {
$entries = ldap_get_entries( $ldapconn, $ldapresult ) ;
if( $entries["count"] ) {
$ldapbind = ldap_bind( $ldapconn, $entries[0]['dn'], $pwd ) ;
if( $ldapbind ) {
echo "Connected: user exists, password checked<br>" ;
}
}
This works ok if I submit the right $name and $pwd
Then I'd like to retrieve some data from the specified user, say
the givenName and sn but can't figure out a way to retrieve those
values using ldap_read or ldap_get_values
For example:
$results = ldap_read($ldapconn, "cn=myname,o=mycompany,c=ch",
'(objectclass=person)', array( "givenname", "sn" ) ) ;
$firstname = ldap_get_values($ldapconn, $results, "givenname" ) ;
$lastname = ldap_get_values($ldapconn, $results, "sn" ) ;
This fails on the ldap_get_values() stating that the supplied resource
is not a valid ldap result entry resource.
If I use something like:
$firstname = ldap_get_values($ldapconn, $ldapresult, "givenname" ) ;
$lastname = ldap_get_values($ldapconn, $ldapresult, "sn" ) ;
It fails too...
What is wrong?
Thanks for any help.
Sincerely,
Steve JORDI
(Remove the K_I_L_LSPAM from my email address)
------------------------------------------------
1197 Prangins Email: stevejordiK_I_L_LSPAM@hotmail.com
Switzerland WWW: www.sjordi.com
------------------------------------------------
Volcanoes at www.sjordi.com/volcanoes
MovieDB at www.sjmoviedb.com
------------------------------------------------
Navigation:
[Reply to this message]
|