• 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
  • 相关阅读:
    ABAP datum_range中的四个组件的作用
    给 visual studio 和 vscode 都换上 JetBrains Mono 字体
    如何安装和使用three.js
    使用 ORM 与原始 SQL 的性能对比
    动态尺寸模型优化实践之Shape Constraint IR Part I
    卫星图像应用 - 洪水检测 使用DALI进行数据预处理
    Java高级技术探索:深入理解JVM内存分区与GC机制
    最大公约数(Python)
    Maven详细总结
    记一次 腾讯会议 的意外崩溃分析
  • 原文地址:https://blog.csdn.net/qq_34486648/article/details/127834949