dongqian3198 2014-09-09 09:50
浏览 127

如何在PHP中实现基于LDAP组的授权?

I am developing a simple site in PHP to enable some users to do some specific tasks. My goal is to achieve role based authorization for the users and they should see different pages according to their LDAP group membership. This is how I'm trying to implement it-

1) use php-ldap library functions to connect to the LDAP server
2) extract the dn of the group name and username by ldapsearch from the user base dn and group base dn
3) search for the "memberOf" attributes in the user entry and match them with the group dn. Return true if matched
4) Search for the "member" attributes in the group entry and match them with the user dn. Return true if matched.

So far I have tested this against an openldap server and it seems to be working, however I want the script to work against other directory servers like apacheds, active directory and 389ds. As I don't have access to multiple directory servers, I want some advise on whether these steps will work on other directory servers or not. Any help regarding this will be appreciated. Thanks in advance.

  • 写回答

1条回答 默认 最新

  • duanqinqiao4844 2014-09-09 13:26
    关注

    These steps will basically work on other LDAP-Servers. You will have to be able to change the attributes you are using though as ActiveDirectory for instance uses the attribute samAccountName where the default LDAP-Scheme uses uid

    And ActiveDirectory does store the group membership in the user-node and not in the group node. So there have to be different approaches for retrieving the group membership.

    Have a look at https://github.com/heiglandreas/kimai/blob/feature/fixLDAPAuthentication/core/libraries/Kimai/Auth/Ldapadvanced.php whih might contain some usefull snippets. It does not take into account the issue with group-membership being defined in the usernode!

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用