Notes on Java, Solaris, PHP, LDAP…

November 17, 2007

LDAP and PHP

Filed under: Uncategorized — negev @ 9:02 pm
Tags: ,

15 June 07
Mysterious empty entries (rows) coming from PHP originating from LDAP
- check for how LDAP raw results are handled
- following causes the above error:

if( !is_array( $result[ 'myMultivaluedAttrib' ] ) ) {
$result[ 'myMultivaluedAttrib' ]= array( $result[ 'myMultivaluedAttrib' ] );
}

Fix: add the following code before the above block:
if( !isset( $result[ 'myMultivaluedAttrib' ] ) ) {
$result[ 'myMultivaluedAttrib' ]= array();
}

LDAP in PHP: ldap_get_entries(..) – it returns single-valued attributes the same way as multi-valued (so you have to access the only value of a single-valued attribute the same way as 1st value of a multi-valued attrib) – except for DN which is returned at the ‘top’ level:
[count] => 4
[dn] => cn=Peter Kehl,ou=…,o=users

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.