简体   繁体   English

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

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

I am developing a simple site in PHP to enable some users to do some specific tasks. 我正在用PHP开发一个简单的站点,以使某些用户能够执行某些特定任务。 My goal is to achieve role based authorization for the users and they should see different pages according to their LDAP group membership. 我的目标是为用户实现基于角色的授权,并且他们应根据其LDAP组成员身份看到不同的页面。 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. 到目前为止,我已经在openldap服务器上对其进行了测试,并且似乎可以正常工作,但是我希望该脚本可以与其他目录服务器(例如apapped,活动目录和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. 提前致谢。

These steps will basically work on other LDAP-Servers. 这些步骤基本上将在其他LDAP服务器上起作用。 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 您将必须能够更改您正在使用的属性,因为例如ActiveDirectory使用属性samAccountName ,其中默认LDAP-Scheme使用uid

And ActiveDirectory does store the group membership in the user-node and not in the group node. 而且ActiveDirectory确实将组成员身份存储在用户节点中,而不是存储在组节点中。 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. 看看https://github.com/heiglandreas/kimai/blob/feature/fixLDAPAuthentication/core/libraries/Kimai/Auth/Ldapadvanced.php ,其中可能包含一些有用的代码片段。 It does not take into account the issue with group-membership being defined in the usernode! 它没有考虑到在usernode中定义的组成员身份的问题!

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

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