简单的LDAP浏览器php版_PHP教程
程序员文章站
2024-04-06 11:06:01
...
这是用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);
?>
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);
?>
推荐阅读
-
简单的LDAP浏览器php版_PHP教程
-
php简单计算页面加载时间的方法,php计算页面加载_PHP教程
-
简单的移动设备检测PHP脚本_PHP教程
-
手把手教你打印出PDF(关于fpdf的简单应用)_PHP教程
-
php与Mysql之间的关系以及一些简单的操作,phpmysql关系_PHP教程
-
简单的php性能注意点,简单php性能_PHP教程
-
简单的方法让你的后台登录更加安全(php中加session验证)_PHP教程
-
自己写的兼容低于PHP 5.5版本的array_column()函数,5.5array_column_PHP教程
-
php简单的上传类分享,php上传分享_PHP教程
-
Joomla简单判断用户是否登录的方法,joomla登录_PHP教程