繁体   English   中英

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

[英]How to achieve LDAP group based authorization in PHP?

我正在用PHP开发一个简单的站点,以使某些用户能够执行某些特定任务。 我的目标是为用户实现基于角色的授权,并且他们应根据其LDAP组成员身份看到不同的页面。 这就是我试图实现的方式-

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.

到目前为止,我已经在openldap服务器上对其进行了测试,并且似乎可以正常工作,但是我希望该脚本可以与其他目录服务器(例如apapped,活动目录和389ds)一起工作。 由于我无权访问多个目录服务器,因此我想对这些步骤是否适用于其他目录服务器提供一些建议。 任何帮助,将不胜感激。 提前致谢。

这些步骤基本上将在其他LDAP服务器上起作用。 您将必须能够更改您正在使用的属性,因为例如ActiveDirectory使用属性samAccountName ,其中默认LDAP-Scheme使用uid

而且ActiveDirectory确实将组成员身份存储在用户节点中,而不是存储在组节点中。 因此,必须有不同的方法来检索组成员身份。

看看https://github.com/heiglandreas/kimai/blob/feature/fixLDAPAuthentication/core/libraries/Kimai/Auth/Ldapadvanced.php ,其中可能包含一些有用的代码片段。 它没有考虑到在usernode中定义的组成员身份的问题!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM