dr6673999 2010-03-17 16:15
浏览 50
已采纳

需要在active-directory中显示用户的信息

The following code will search for the user within the domain controller, but I want to display the info of each thing noted within the justthese variable: "displayname","mail","samaccountname","sn","givenname","department","telephonenumber"

$dn = "dc=xxx,dc=xxx";
$justthese = array("displayname","mail","samaccountname","sn","givenname","department","telephonenumber");

$sr=ldap_search($ldapconn, $dn,'SAMAccountName=username', $justthese);

$info = ldap_get_entries($ldapconn, $sr);

echo "<h3>".$info["count"]." entries returned</h3>";

foreach($justthese as $key=>$value){
    print '<p><strong>'.$value.'</strong></p>';
}

It displays each item within the $justthese array, I want to display the info for that user for each thing noted in $justthese array.

Right now it outputs it like this:

displayname

mail

samaccountname

sn

givenname

department

telephonenumber

I want it to have the actual data to the right of it, which I know I am doing something wrong with the foreach loop, any help is appreciated.

So it'd look like this

displayname Chuck

mail chuck@norris.com

samaccountname chucknorris

sn chuckisthebest

givenname Chuck Norris

department Security

telephonenumber 555-555-5555

  • 写回答

2条回答 默认 最新

  • douzhangli9563 2010-03-17 16:58
    关注

    Assuming your $info returns just one user: (though you should probably loop through the user array or at least print_r it to see what it's returning)

    foreach($justthese as $key=>$value){
        print '<p><strong>'.$value.' ' . (isset($info[0][$value]) ? $info[0][$value] : 'empty') . '</strong></p>';
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?