This is an LDAP browser written in PHP. you can learn from this program how to access LDAP. if (! Isset ($ host) $ hostlocalhost; if (! Isset ($ port) $ port389; if (! Isset ($ dn) $ dndcmy-domain, dccom; if (! Isset ($ filter) $ filt
This is an LDAP browser written in PHP. you can learn from this program how to use PHP to access LDAP.
If (! Isset ($ host) $ host = localhost;
If (! Isset ($ port) $ port = 389;
If (! Isset ($ dn) $ dn = dc = my-domain, dc = com;
If (! Isset ($ filter) $ filter = objectclass = *;
$ Con = ldap_connect ($ host, $ port) or die (ldap_connect error );
Echo
. Chr (13 );
// Read this object
$ Rst = ldap_read ($ con, $ dn, $ filter) or die (ldap_read error );
$ Entry = ldap_first_entry ($ con, $ rst) or die (ldap_first_entry error );
Echo $ dn.:. chr (13 );
$ Attrs = ldap_get_attributes ($ con, $ entry );
$ Attrs_count = $ attrs [count];
For ($ I = 0; $ I <$ attrs_count; $ I ++ ){
Echo. $ attrs [$ I]. chr (13 );
$ Values = ldap_get_values ($ con, $ entry, $ attrs [$ I]);
$ Values_count = $ values [count];
For ($ j = 0; $ j <$ values_count; $ j ++) echo. $ values [$ j]. chr (13 );
}
Ldap_free_result ($ rst );
// Get all objects of this entry
$ Rst = ldap_list ($ con, $ dn, $ filter) or die (ldap_list error );
$ Count = ldap_count_entries ($ con, $ rst );
If ($ count ){
Echo all objects of this entry :--------------------------------------------------------------------------------;
$ Entry = ldap_first_entry ($ con, $ rst );
While ($ entry ){
$ Entry_dn = ldap_get_dn ($ con, $ entry );
Echo. $ entry_dn .. chr (13 );
$ Entry = ldap_next_entry ($ con, $ entry );
}
}
Ldap_free_result ($ rst );
Ldap_close ($ con );
Echo returns. chr (13 );
Echo
. Chr (13 );
?>