duanpei4455 2018-09-08 16:39
浏览 70

如何从PHP / CodeIgniter中的活动目录中获取用户经理的sam帐户或电子邮件ID

I recently wanted to integrate Active directory in one of my projects. I created web app with CodeIgniter and used this AD library to integrate AD.

https://github.com/kathmann/Auth_AD

Now it does everything I need, except I cannot get manager's samaccountname or email id.

For example I want to fetch one user 'xyz' all details, I used predefine function from the library which is

get_all_user_data('xyz');

This is getting me all the details and for manager, I am getting below details.

CN=ABC DEF, OU=Users,OU=example1,OU=example2,OU=Sites,DC=example3,DC=example4,DC=example5

Now I want to fetch samaccountname and email of the above. But i am not sure how to do it.

Just let me know what to code further and convert above string to samaccountname and email of the user.

I already saw this thread: ldap filter for distinguishedName

The person question is same as mine but I didn't understand what the answer says. I tried the answer but it gets all the user who has same manager instead the actual manager user.

  • 写回答

1条回答 默认 最新

  • douyue3800 2018-09-09 05:04
    关注

    Since you've already found out the manager's value for the said user, you already have the CN value for the manager in the same DN.

    Manager's DN = CN=ABC DEF,   # // OUs placed below for sake of understanding
    OU=Users,OU=example1,OU=example2,OU=Sites,DC=example3,DC=example4,DC=example5
    

    You should create another filter on this CN value of the manager ("CN=ABC DEF" for the manager derived above), and then retrieve the values of mail and samaccountname attribute.

    Your search filter should be: "(&(objectCategory=person)(objectClass=user)(cn=ABC DEF))". Now you should be able to fetch this user (manager here) and its detailed information, based on this CN filter.

    评论

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊