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)) $ ...