1

我一直在尝试将此 dlif 应用于我的 openldap 服务器:

$ cat acl.ldif
dn: olcDatabase={1}hdb,cn=config
changetype: modify
add: olcAccess
olcAccess: {3}to dn.exact="cn=ldap-city-thedomain-com,dc=repl,dc=thedomain,dc=com" attrs="ipServicePort,description" by dn="mail=itops@thedomain.com,ou=people,dc=thedomain,dc=com" write by * read

我相信这应该允许具有 DN:"mail=itops@thedomain.com,ou=people,dc=thedomain,dc=com"的用户更新属性 ipServicePort 和描述"cn=ldap-city-thedomain-com,dc=repl,dc=thedomain,dc=com"

这似乎适用:

$ sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f acl.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={1}hdb,cn=config"

当我搜索它时,我可以找到我更新的条目:

$ sudo ldapsearch -Y EXTERNAL -H ldapi:// -b cn=config 'olcDatabase={1}hdb'
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
# extended LDIF
#
# LDAPv3
# base <cn=config> with scope subtree
# filter: olcDatabase={1}hdb
# requesting: ALL
#
# {1}hdb, config
dn: olcDatabase={1}hdb,cn=config
objectClass: olcDatabaseConfig
objectClass: olcHdbConfig
olcDatabase: {1}hdb
olcDbDirectory: /var/lib/ldap
olcSuffix: dc=thedomain,dc=com
olcAccess: {0}to attrs=userPassword,shadowLastChange by self write by anonymou
s auth by dn="cn=admin,dc=domain,dc=ie,dc=aws,dc=thedomain,dc=net" write by * n
one
olcAccess: {1}to dn.base="" by * read
olcAccess: {2}to * by dn="cn=admin,dc=domain,dc=ie,dc=aws,dc=thedomain,dc=net" w
rite by * read
olcAccess: {3}to dn.exact="cn=ldap-city-thedomain-com,dc=repl,dc=thedomain,
dc=com" attrs="ipServicePort,description" by dn="mail=itops@thedomain.com,ou=p
eople,dc=thedomain,dc=com" write by * read
olcLastMod: TRUE
olcRootDN: cn=admin,dc=thedomain,dc=com
olcRootPW: {SSHA}HASHEDPW
olcSyncrepl: {0}rid=003 provider=ldap://ldap.city.thedomain.com binddn="cn
=admin,dc=thedomain,dc=com" bindmethod=simple credentials=Cju8MJZhegnEgKp2nU s
earchbase="dc=thedomain,dc=com" type=refreshAndPersist interval=00:00:00:10 re
try="5 5 300 5" timeout=1
olcSyncrepl: {1}rid=004 provider=ldap://ldap1.domain.ie.aws.thedomain.net binddn
="cn=admin,dc=thedomain,dc=com" bindmethod=simple credentials=Cju8MJZhegnEgKp2
nU searchbase="dc=thedomain,dc=com" type=refreshAndPersist interval=00:00:00:1
0 retry="5 5 300 5" timeout=1
olcMirrorMode: TRUE
olcDbCheckpoint: 512 30
olcDbConfig: {0}set_cachesize 0 2097152 0
olcDbConfig: {1}set_lk_max_objects 1500
olcDbConfig: {2}set_lk_max_locks 1500
olcDbConfig: {3}set_lk_max_lockers 1500
olcDbIndex: objectClass eq
olcDbIndex: entryCSN eq
olcDbIndex: entryUUID eq
# search result
search: 2
result: 0 Success
# numResponses: 2
# numEntries: 1

但是,当我尝试使用这些凭据进行更改时,它仍然失败:

$ cat /tmp/modify.ldif
dn: cn=ldap-city-thedomain-com,dc=repl,dc=thedomain,dc=com
changetype: modify
replace: ipServicePort
ipServicePort: 1485176342

dn: cn=ldap-city-thedomain-com,dc=repl,dc=thedomain,dc=com
changetype: modify
replace: description
description: Updated by ldap.city.thedomain.com on Mon Jan 23 12:59:02 UTC 2017

跑步:

$ ldapmodify -H ldap://localhost -w PASSWORD -D "mail=itops@thedomain.com,ou=people,dc=thedomain,dc=com" -f /tmp/modify.ldif        
modifying entry "cn=ldap-city-thedomain-com,dc=repl,dc=thedomain,dc=com"
ldap_modify: Insufficient access (50)

我还尝试让我的 ACL 的限制稍微少一些,以尝试了解什么不起作用,我尝试了以下 acl.ldif 文件:

dn: olcDatabase={1}hdb,cn=config
changetype: modify
add: olcAccess
olcAccess: {3}to dn="cn=ldap-city-thedomain-com,dc=repl,dc=thedomain,dc=com" attrs="ipServicePort,description" by dn="mail=itops@thedomain.com,ou=people,dc=thedomain,dc=com" write by * read

结果是一样的

dn: olcDatabase={1}hdb,cn=config
changetype: modify
add: olcAccess
olcAccess: {3}to dn="cn=ldap-city-thedomain-com,dc=repl,dc=thedomain,dc=com" by dn="mail=itops@thedomain.com,ou=people,dc=thedomain,dc=com" write by * read

结果是一样的

dn: olcDatabase={1}hdb,cn=config
changetype: modify
add: olcAccess
olcAccess: {3}to * by dn="mail=itops@thedomain.com,ou=people,dc=thedomain,dc=com" write by * read

结果是一样的

我唯一没有尝试的事情是,因为我希望避免使数据库变得如此不安全,即使在测试期间也是如此,是允许 * 写入此记录,或 * 写入所有记录。

我已经从 Apache Directory Studio 获取了我想要允许编辑的记录的 dn,它向我显示:

DN: cn=ldap-city-thedomain-com,dc=repl,dc=thedomain,dc=com

和我的用户 DN 相同:

DN: mail=itops@thedomain.com,ou=people,dc=thedomain,dc=com

我确信我在做一些明显愚蠢的事情,因为我对 ldap 的了解很差,而且阅读文档对我来说很痛苦。我希望有人能发现我明显的错误并提出更正建议,因为经过大量时间的修补,我看不出我做错了什么。

4

1 回答 1

0

感谢#openldap IRC 中的JoBbZ。这是我的一个简单的误解。ACL 规则中的顺序事项。LDAP 将停止查找第一个匹配项,因此我需要将我的 olcAccess 保存为 2 而不是 3

于 2017-01-23T16:22:58.190 回答