Simple LDAP browser php _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Simple LDAP browser for php. 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) $ 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 );
?>

Response. if (! Isset ($ host) $ host = localhost; if (! Isset ($ port) $ port = 389; if (! Isset ($ dn) $...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.