1

我有一个运行结构的 LDAP 服务器:

dc=example,dc=ldap
   dc=organisations
      o=orga1 (objectClasses top/organisation/dcObject)
         cn=ADMINS (objectClasses top/groupOfNames)
         cn=USER
      o=orga2 
         cn=ADMIN
         cn=USER
      cn=users (objectClasses top/organisation/dcObject)
         cn=user1 (objectClasses top/person)
         cn=user2

现在我想添加一些规则,只有组织组中的用户才能看到组织。

硬编码方法很容易实现:

olcAccess: {1}to dn.subtree="o=orga1,dc=organizations,dc=example,dc=ldap"
  by group.exact="cn=ADMINS,o=orga1,dc=organizations,dc=example,dc=ldap" write
  by group.exact="cn=USER,o=orga1,dc=organizations,dc=example,dc=ldap" read
  by * none

(重要的是在'by'前面写两个空格[这对我来说是很长一段时间的问题])

但是我不想为每个新组织实施这些规则,所以我尝试用一​​些正则表达式来实施规则。但我失败得很惨:

olcAccess: {1}to dn.regex="^o(.+),dc=organizations,dc=example,dc=ldap$"
  attrs=children
  by group.exact="cn=ADMINS,o=[$1],dc=organizations,dc=example,dc=ldap$" write
  by group.exact="cn=USER,o=[$1],dc=organizations,dc=example,dc=ldap$" read
  by * none

这条规则没有任何影响。那么有人有什么想法来解决我的问题吗?

还是不能像我一样对成员进行分组?

再次感谢

4

1 回答 1

0

在邮件列表中,我得到了 group.exact 没有进行正则表达式评估的提示。

作为一种解决方法,我创建了自己的 objectClass,其属性为“orgaMember”和“orgaAdmin”,现在可以基于这些属性创建 olcAccess 规则。要将此规则应用于所有组织,可以使用正则表达式。

olcAccess: {1}to dn.regex="^o=(.+),dc=organizations,dc=example,dc=ldap$"
 by dnattr=orgaAdmin write
 by dnattr=orgaMember read
 by * none

我希望这会对某人有所帮助。

PS。要更新 objectClasses 需要注意很多事情。见http://www.zytrax.com/books/ldap/ch6/slapd-config.html

于 2015-08-20T07:21:56.910 回答