OpenLDAP限制匿名访问只能看到条目属性而不能扫描整个数据库

我们有一个OpenLDAP(2.4.45)服务器,其中包含我们所有的用户,组,sudo规则等。

我需要将新应用程序连接到此服务器,但是此应用程序要求匿名用户可以读取属性(它将知道它需要读取属性的确切DN)。

现在假设结构为:

o=Example(dc=example,dc=com) ou=People uid=user1 uid=user2 ou=Groups cn=group1 cn=group2 

我需要限制匿名用户如果知道确切的dn(比如dn =“uid = user1,ou = People,dc = example,dc = com”),并且完全无法发现其他logging(如果他们不知道确切的dn给他们)。

通过OpenLDAP文档阅读我假设下面的ACL应该工作:

 olcAccess: {0}to dn.children="ou=Groups,dc=example,dc=com" by * read break olcAccess: {1}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage by anonymous none stop by * read 

然而,似乎breakstop不产生预期的结果作为直接查询“cn = test,ou =组,dc = example,dc = com”导致No such object (32)

什么是实现上述的正确方法?

其实答案很简单(在IRC中指出):

ACL应如下所示:

 olcAccess: {0}to dn.children="ou=Groups,dc=example,dc=com" by anonymous stop by * read break olcAccess: {1}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage by anonymous none stop by * read 

请注意{0}中的stop行,在原来的ACL中,它首先提供读取访问权限,但是由于break ,在新版本中删除了匿名显式授予的读取访问权限,然后OpenLDAP通知停止处理此请求的ACL。