• Linux OpenLDAP配置ACL


    版本 CentOS

    1、禁止匿名访问

    默认情况下匿名用户可以获取所有用户信息,甚至是密码字段,虽然密码字段是经过加密的那也很危险
    创建disable_anon.ldif文件

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    导入配置

    ldapadd -Q -Y EXTERNAL -H ldapi:/// -f disable_anon.ldif

    2、设置ACL

    1. 拒绝所有用户查看用户信息,并且添加有ldap管理账号
      创建acl.ldif
    dn: olcDatabase={2}hdb,cn=config
    changetype: modify
    replace: olcAccess
    olcAccess: to attrs=userPassword
      by anonymous auth
      by dn.base="cn=ldapadmin,ou=manage,dc=taovip,dc=com" write
      by * none
    olcAccess: to *
      by anonymous auth
      by dn.base="cn=ldapadmin,ou=manage,dc=taovip,dc=com" write
      by dn.base="cn=ldapread,ou=manage,dc=taovip,dc=com" read
      by * none
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    导入配置

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

    1. 删除ACL
      创建文件del_acl.ldif
    dn: olcDatabase={2}hdb,cn=config
    changetype: modify
    delete: olcAccess
    olcAccess: {0}
    
    • 1
    • 2
    • 3
    • 4

    ldapmodify -Q -Y EXTERNAL -H ldapi:/// -f del_acl.ldif

    3、本人实践说明:

    ACL配置:

    1. 如下设置:

    只有管理员能修改密码,及管理员能查看所有目录
    其他账号不能修改密码,不能查看所有目录

    dn: olcDatabase={2}hdb,cn=config
    changetype: modify
    replace: olcAccess
    olcAccess: to attrs=userPassword
      by anonymous auth
      by dn.base="cn=Manager-Fxd,dc=fxd-ldap,dc=com" write
      by * none
    olcAccess: to *
      by anonymous auth
      by dn.base="cn=Manager-Fxd,dc=fxd-ldap,dc=com" write
      by dn.base="cn=Manager-Fxd,dc=fxd-ldap,dc=com" read
      by * none
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    2. 如下配置:

    所有用户需要权限校验
    超管账号可以查看和编辑所有目录和属性
    ou=People,dc=fxd-ldap,dc=com下的用户,可以查看除超管外的其他目录,查看不到密码属性

    dn: olcDatabase={2}hdb,cn=config
    changetype: modify
    replace: olcAccess
    olcAccess: to attrs=userPassword
      by anonymous auth
      by dn.base="cn=Manager-Fxd,dc=fxd-ldap,dc=com" write
      by * none
    olcAccess: to dn.base="cn=Manager-Fxd,dc=fxd-ldap,dc=com"
      by anonymous auth
      by self write
      by self read
      by * none
    olcAccess: to *
      by anonymous auth
      by dn.subtree="ou=People,dc=fxd-ldap,dc=com" write
      by dn.subtree="ou=People,dc=fxd-ldap,dc=com" read
      by * none 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
  • 相关阅读:
    【算法题】100032. 使数组为空的最少操作次数
    关于js中数组push之后长度明明有但是获取长度和随意的数组下标的时候不正常的问题
    javaee springMVC日期类型转换之通过注解的方式
    腾讯:《智能科技 跨界相变——2024数字科技前沿应用趋势》
    何时使用Elasticsearch而不是MySql?
    Linux文件:/etc/fstab
    git命令合并某一个分支的某个commit到目标分支
    CSP-J CSP-S NOIP 省选 NOI 游记 总结 经验等
    C++ Reference: Standard C++ Library reference: C Library: ctime: asctime
    酷快讯:Eminem和Snoop Dogg无聊猿新MV加持后ApeCoin上涨22%
  • 原文地址:https://blog.csdn.net/qq_34486648/article/details/127834949