安装好了openldap之后,就是对它进行配置了,其中一项就是设置访问控制,限制普通用户只能修改/访问他们能修改/访问的项。这就是ACL需要做的事情。
设置方法
ACL设置语法
1.语法
access to what:
by who access control
其中,access to指示启用访问控制,上句大致可以理解为:
access to <对什么目标进行控制>[by <作用于哪些访问者> <授予什么样的访问权限><采取什么样的匹配控制动作>]+
2.剖析
2.1 控制目标 what
这一域主要是实现对ACL应用对象的指定,对象可以是记录和属性。选择ACL目标记录的方法一般有两种:DN和filter,语法为:
what ::= * |
[dn[.basic-style]=regex | dn.scope-style=DN]
[filter=ldapfilter] [attrs=<attrlist>]
2.1.1 指定所有的记录
access to *
2.1.2 通过DN指定
语法如下:
to dn[.basic-style]=regex
basic-style ::= regex | exact
to dn.scope-style=DN
scope-style ::= base | one | subtree | children
第一种方法是使用正则表达式(dn.regex)或精确匹配(dn.style)的方式来匹配符合条件的记录(这个好像不像想象的那么简单,实现起来颇为费脑筋),例如:
access to dn="^.*,uid=([^,]+),ou=users,(.*)$"
2.1.3 通过filter匹配记录
通过filter指定过滤规则进行记录过虑,语法如下:
access to filter=ldap filter
其中filter指定的为search的过滤规则,这类同于linux系统中grep的匹配方式。如:
access to filter=(objectClass=sambaSamAccount)
也可以结合使用DN和filter进行记录的匹配,例如:
access to dn.subtree=”ou=users,dc=mydomain,dc=org” filter=(objectClass=posixAccount)
2.1.4 通过attrs选取匹配记录
2.2 被用来授权的访问者的指定
2.3 被授予的权限access
2.4 采取什么样的匹配控制动作control
在进行记录的匹配时,如果有多条规则存在,那么在第一次匹配产生后是否还进行后续的匹配或采取其它的动作将取决于此项的设置;控制方式共有以下三种:
2.5 一个例子
access to dn.chilren="ou=users,dc=mydomain,dc=org"
attrs=userPassword #指定“密码”属性
by self write #用户自己可更改
by * auth #所有访问者需要通过认证
by dn.children="ou=admins,dc=mydomain,dc=org" write #管理员组的用户可更改
access to dn.subtree="ou=SUDOers,dc=test,dc=com" #SUDOers的所有内容必须提供其他匿名可读,不然在linux上切换到该用户,不能使用sudo
#其他用户可读
by dn="cn=Manager,dc=test,dc=com" write
by * read
access to attrs="gidNumber,homeDirectory,loginShell,uidNumber,sshPublicKey"
by * read #对这些属性只能读,但是userPassword字段是可写的,允许用户自行修改密码,但是不能修改自己的gid,home目录等
access to *
by anonymous read #匿名访问可读
by self write #自己可写
by users read
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/233230.html原文链接:https://javaforall.net