首页 > 解决方案 > centos 7上的LDAP配置ACL

问题描述

我正在尝试为 Manager 用户设置 ACL,因为我知道我的语法错误在哪里。

修改“olcDatabase={2}hdb”文件是否正确??

我的终端命令:

ldapmodify -a -x -D "cn=Manager,dc=gruppo6,dc=labreti,dc=it" -w root -H ldap:// -f acl.ldif

这是错误:

ldapmodify: invalid format (line 5) entry: "olcDatabase={2}hdb"

acl.ldif:

dn: olcDatabase={2}hdb
changetype: modify
add: olcAccess
olcAccess:{0} to * by dn="cn=Manager,dc=gruppo6,dc=labreti,dc=it" manage by * break
{1} to attrs=userPassword by dn="cn=Manager,dc=gruppo6,dc=labreti,dc=it" write by self write by anonymous none by users none
{2} to attrs=loginShell by dn="cn=Manager,dc=gruppo6,dc=labreti,dc=it" write by self read by anonymous none by users none to attrs=uid,sn,homeDirectory by self write
{3} to dn.subtree="dc=gruppo6,dc=labreti,dc=it" by * read

olcDatabase={2}hdb.ldif:

# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.
# CRC32 0c9c7626
dn: olcDatabase={2}hdb
objectClass: olcDatabaseConfig
objectClass: olcHdbConfig
olcDatabase: {2}hdb
olcDbDirectory: /var/lib/ldap
olcDbIndex: objectClass eq,pres
olcDbIndex: ou,cn,mail,surname,givenname eq,pres,sub
structuralObjectClass: olcHdbConfig
entryUUID: 05c622d2-9007-1039-808a-1106615e0d2d
creatorsName: cn=config
createTimestamp: 20191031084858Z
olcRootPW:: e1NTSEF9QXNRTGdiYjZ0RTltMjMwbHdFcW5VeE5ETzNxcE1qSXE=
olcSuffix: dc=gruppo6,dc=labreti,dc=it
olcRootDN: cn=Manager,dc=gruppo6,dc=labreti,dc=it
entryCSN: 20191031122732.077139Z#000000#000#000000
modifiersName: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
modifyTimestamp: 20191031122732Z

感谢大家的帮助

标签: ldapcentos7acl

解决方案


有2个问题:

  • 您正在尝试在acl.ldifolcDatabase={2}hdb中使用错误的 dn 进行修改,该条目应位于 的子树中。您可以使用以下命令获取目标 olcDatabase:cn=config

    slapcat -n 0 -a olcDatabase=hdb
    
    # Output 
    dn: olcDatabase={2}hdb,cn=config
    ...
    
  • 由于您正在修改现有条目,因此您不需要在命令中使用-a标志 ( ldapadd ) :ldapmodify

    ldapmodify -x -D "cn=Manager,dc=gruppo6,dc=labreti,dc=it" -w root -H ldap:// -f acl.ldif
    

如果您的 ldap 管理器由于权限不足(从此指令读取to * by dn="cn=Manager,dc=gruppo6,dc=labreti,dc=it" manage)而无法修改此配置条目,您仍然可以使用外部绑定(unix 用户)来执行此类操作:

ldapmodify -Y EXTERNAL -H ldapi:/// -f acl.ldif 

推荐阅读