簡單的LDAP瀏覽器php版_PHP教程

來源:互聯網
上載者:User
這是用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;$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 返回.chr(13);

echo
.chr(13);
?>

http://www.bkjia.com/PHPjc/532169.htmlwww.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)) $...

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.