php ldap off warning,ldap_get_dn

这篇博客介绍如何通过PHP的ldap_connect和ldap_search函数,结合samaccountname(如'john.doe'),从指定的OU和DC中检索对应的DN。示例代码展示了如何建立连接、绑定、搜索及获取DN的过程。
摘要由CSDN通过智能技术生成

[#1]

radulescuiuliamaria at yahoo dot com [2015-09-29 08:50:37]

How to get the DN for a given samaccountname:

$ldap_conn = ldap_connect($hostname, $port);

$bind = ldap_bind($ldap_conn, $username, $password);

$samaccountname = john.doe;

$filter="(samaccountname=$samaccountname)";

$dn="OU=PEOPLE, DC=example, DC=com"; //even if it seems obvious I note here that the dn is just an example, you'll have to provide an OU and DC of your own

$res = ldap_search($ldap_conn, $dn, $filter);

$first = ldap_first_entry($ldap_conn, $res);

$data = ldap_get_dn($ldap_conn, $first);

echo "The desired DN is: ".$data;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值