It has been mentioned in the comments below, but the <?php ldap_get_entries($connection,$result) ?> always makes all attributes into lower-case. I found out the hard way that if I'm running an ldap query against the corporate AD and then want to display some results, nothing is actually displayed unless the attribute names area in lower-case.

If you're dealing with Active Directory and need to get values like 'lastlogon', 'pwdlastset' or similar, you'll notice that AD gives the values as Windows FILETIME timestamps. That means, the values are 100-nanosecond units passed since 1.1.1600 00:00:00.

To convert these to unix timestamps which PHP's date functions understand, one easy way would be the following :

Actually, the fact that ldap_get_entries returns attribute names as lowercase is really annoying, because ldap_get_attributes apparently does not. This is really annoying, especially when having arrays of attribute names and having to worry about which call was used to retrieve entries from LDAP.

If you loop over the entries, like$entries = ldap_get_entries( $ds, $sr );watch out!you have to check with is_null the last entrybecause you will get one entry more than the search found,but the last one will be nullso you are safe if you do:for ( $i = 0; $i < count( $entries ); $i++ ) { if ( is_null( $entries[ $i ] ) ) continue; ...}

Note that ldap_get_entries return an associative array with the attributes in lower case. So for example the givenName ldap attribute is associated with $ldap[0]["givenname"][0] (for the first given name for the first result) this is a little confusing at first.