Home > Backend Development > PHP Tutorial > Simple LDAP browser php version_PHP tutorial

Simple LDAP browser php version_PHP tutorial

WBOY
Release: 2016-07-13 17:24:16
Original
980 people have browsed it

这是用PHP写的LDAP浏览器,您可以从这个程序中了解到如何用PHP来访问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;$iecho .$attrs[$i].chr(13);
$values = ldap_get_values($con,$entry,$attrs[$i]);
$values_count = $values[count];
for($j=0;$j}
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 返回.chr(13);

echo
.chr(13);
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/532169.htmlTechArticle这是用PHP写的LDAP浏览器,您可以从这个程序中了解到如何用PHP来访问LDAP. if(!isset($host)) $host = localhost; if(!isset($port)) $port = 389; if(!isset($dn)) $...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template