Simple LDAP browser PHP version _php tutorial

Source: Internet
Author: User
Tags ldap
This is the 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);
?>

http://www.bkjia.com/PHPjc/532169.html www.bkjia.com true http://www.bkjia.com/PHPjc/532169.html techarticle This is the LDAP browser written in PHP, you can learn from this program how to access LDAP with PHP. if (!isset ($host)) $host = localhost, if (!isset ($port)) $port = 389; Isset ($DN)) $ ...

  • Related Article

    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.