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

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: