LDAP:创建具有有限权限的绑定用户

lor*_*zog 5 openldap ldap authentication

我需要绑定到 OpenLDAP 服务器来对用户进行身份验证,但我不希望这个低权限或“委派管理员”能够看到比严格必要的更多的属性。

如何使用白名单减少绑定用户可以看到的属性?哪些属性是对用户进行身份验证所必需的?

例如,这个特定的绑定用户不需要查看NTPassword,我想其他属性,如主目录等。

这是我到目前为止所做的:

  1. 我已禁用匿名绑定:

    # disable anon bind
    dn: cn=config
    changetype: modify
    add: olcDisallows
    olcDisallows: bind_anon
    
    dn: cn=config
    changetype: modify
    add: olcRequires
    olcRequires: authc
    
    dn: olcDatabase={-1}frontend,cn=config
    changetype: modify
    add: olcRequires
    olcRequires: authc
    
    Run Code Online (Sandbox Code Playgroud)
  2. 我创建了一个“应用程序”OU 和一个“gitlab”用户:

    # file: applications.ldif
    dn: ou=Applications,dc=example,dc=com
    objectclass: top 
    objectClass: organizationalunit
    ou: Applications
    
    dn: cn=gitlab,ou=Applications,dc=example,dc=com
    cn: gitlab
    objectClass: simpleSecurityObject
    objectClass: organizationalRole
    userPassword: {CRYPT}.....
    
    Run Code Online (Sandbox Code Playgroud)
  3. 要创建用户,我使用了 LDAP 管理员用户:

    ldapadd -xvvv -f applications.ldif -D 'cn=admin,dc=example,dc=com' -W
    
    Run Code Online (Sandbox Code Playgroud)
  4. 为了限制“gitlab”权限,我试过这个:

    # file: give-applications-access.ldif
    dn: cn=config
    changetype: modify
    # allow Applications (e.g. GitLab) access to userPassword
    access to dn.chidren="ou=People,dc=example,dc=com" attrs=userPassword
      by dn.exact="ou=Applications,dc=eaxmple,dc=com" read
    
    Run Code Online (Sandbox Code Playgroud)
  5. 然后我已经习惯ldapmodify了应用以前的LDIF:

    ldapmodify -xvvv  -D 'cn=admin,dc=example,dc=com' -W -f give-applications-access.ldif
    
    Run Code Online (Sandbox Code Playgroud)

现在我可以ou=People从 gitlab成功验证用户身份。不过,如果我使用如jxplorerldapsearchgitlab用户凭据,我可以看到所有的用户属性除了userPassword的:

ldapsearch -h ldaps://ldap.example.com -p 636 -LLL -D 'cn=gitlab,ou=Applications,dc=example,dc=com' -s base -b "ou=People,dc=example,dc=com"  -s sub -W "(objectclass=*)" | grep -i userpassword | wc -l
0
Run Code Online (Sandbox Code Playgroud)

这里发生了什么?我想 gitlab 是sambaNTPassword用来进行身份验证的……但我认为它attrs=userPassword是只读的,现在它甚至不在属性中。

抱歉粘贴所有命令 - 我将它们留在这里,希望其他人会发现这很有用。我找到的大部分文档都描述了每个可用的选项,但没有给出任何可用于最新版本的 OpenLDAP 的好例子;并且大多数可用的示例涉及编辑 slapd.conf 而不是“新”数据库 (cn=config) 类型,因此很难理解什么是相关的。

更新 - 当前的 ACL 是:

olcAccess: {0}to attrs=userPassword by self write by anonymous auth by * none
olcAccess: {1}to attrs=shadowLastChange by self write by * read
olcAccess: {2}to * by * read
Run Code Online (Sandbox Code Playgroud)

我已经按照这个答案阅读了在我的情况下使用的 ACL {0}mdbldapsearch -Y EXTERNAL -H ldapi:/// -b cn=config 'olcDatabase={1}mdb'