openldap:用ACL控制访问权限 - 图文

2026/1/15 3:47:10

by anonymous auth

This example applies to entries in the \homePhone, an entry can write to itself, entries under example.com entries can search by them, anybody else has no access (implicit by * none) excepting for authentication/authorization (which is always done anonymously). The homePhone attribute is writable by the entry, searchable by entries under example.com, readable by clients connecting from network 10, and otherwise not readable (implicit by * none). All other access is denied by the implicit access to * by * none. Sometimes it is useful to permit a particular DN to add or remove itself from an attribute. For example, if you would like to create a group and allow people to add and remove only their own DN from the member attribute, you could accomplish it with an access directive like this:

access to attr=member,entry by dnattr=member selfwrite

The dnattr selector says that the access applies to entries listed in the member attribute. The selfwrite access selector says that such members can only add or delete their own DN from the attribute, not other values. The addition of the entry attribute is required because access to the entry is required to access any of the entry’s attributes. 例子3

access to dn=”.*,dc=it,dc=com” attr=userPassword by dn=”cn=root,dc=it,dc=com” write by self write

by * auth

access to dn=”.*,dc=it,dc=com” attr=mail by dn=”cn=root,dc=it,dc=com” write by self write by * read

access to dn=”.*,ou=people,dc=it,dc=com” by * read

access to dn=”.*,dc=it,dc=com” by self write

by * read

上面的配置仅允许 userPassword 属性的所有者修改项,但仅当所有者提供他或她的优先密码时才允许进行修改。在所有其它情况下,只能出于认证目的来访问该项,而不能查看它。第二个access to项允许用户修改自己的电子邮件地址(attr=mail)。第三个项指定除了 rootdn 外,对于所有人,ou=people,dc=it,dc=com 中的任何 DN 都是只读的。这可防止用户更改其用户名、uid、gid 和主目录等。最后,最后一项是包容前面访问控制中未涉及的任何东西的安全的“大杂烩”。例如,它允许用户更改其自己地址簿中的项。

第三部分 总结

访问控制列表的最后说明: 3.1语法

access to [by ]+

其中,access to指示启用访问控制,上句大致可以理解为: access to <对什么目标进行控制>[by <作用于哪些访问者> <授予什么样的访问权限><采取什么样的匹配控制动作>]+

3.2 剖析

3.2.1 控制目标

这一域主要是实现对ACL应用对象的指定,对象可以是记录和属性。选择ACL目标记录的方法一般有两种:DN和filter,语法为:

::= * |[dn[.]= | dn.=][filter=] [attrs=]

3.2.1.1 指定所有的记录

access to *

3.2.1.2 通过DN指定 语法如下:

to dn[.]= ::= regex | exact to dn.= ::= base | one | subtree | children

第一种方法是使用正则表达式(dn.regex)或精确匹配(dn.style)的方式来匹配符合条件的记录(这个好像不像想象的那么简单,实现起来颇为费脑筋),例如:

access to dn=\

第二种方法通过“区域”选择的方法进行目标记录的选取,对以指定的DN开始的目录树区域进行目标记录匹配。匹配区域的方式共有四种:

base只匹配DN本身一条记录

one匹配以给定DN为父目录的所有记录

subtree匹配以给定DN为根目录的所有子树内的记录 children匹配给定DN下的所有记录,但应该不包括以DN直接命名的那条记录(参见例子的解释)

例如:对于

0: dc=mydomain,dc=org

1: cn=root,dc=mydomain,dc=org

2: ou=users,dc=mydomain,dc=org

3: uid=samba,ou=users,dc=mydomain,dc=org

4: cn=Administator,uid=samba,ou=users,dc=mydomain,dc=org 5: uid=guest,ou=users,dc=mydomain,dc=org

规则 dn.base=\ 只会匹配记录2

规则 dn.one=\匹配记录3和记录5,记录4是记录3的子目录,故不算在内

规则 dn.subtree=\匹配记录2、3、4、5

规则 dn.children=\ 匹配记录3、4、5,因为记录0、1和2都是以DN直接命名的,故不匹配

3.2.1.3 通过filter匹配记录

通过filter指定过滤规则进行记录过虑,语法如下:

access to filter=

其中filter指定的为search的过滤规则,这类同于linux系统中grep的匹配方式。如: access to filter=(objectClass=sambaSamAccount)

也可以结合使用DN和filter进行记录的匹配,例如:

access to dn.subtree=\3.2.1.4 通过attrs选取匹配记录 语法:

attrs= 例如:

access to attrs=uid,uidNumber,gidNumber

也可以结合使用DN和attrs进行记录的匹配,例如: access to dn.subtree=\3.2.2 被用来授权的访问者的指定

指定被授权的用户范围的方法大致有以下几种: 所有的访问者,包括匿名的用户 anonymous非认证的匿名用户 users认证的用户 self目标记录的用户自身

dn[.]=在指定目录内匹配正则表达式的用户 dn.=指定DN内的用户 例如:

by dn.subtree=\3.2.3 被授予的权限

当选取好ACL作用的目标记录并选取好用户范围后,就该给这些用户授予他们应该得到的权限了。大致的权限(由低到高)有以下几类:

none无权限,即拒绝访问 auth访问bind(认证)设置的权限;前提是需要用户提交一个DN形式的用户名并能通过认证

compare比较属性的权限;(例如:对照查看某用户的telephoneNumber值是不是158 8888 8888),但并不具有搜索的权限

search利用过虑条件进行搜索的权限,但这并不一定具有可读取搜索结果的权限 read读取搜索结果的权限

write更改记录属性值的权限 注意:可以在slapd.conf文件中通过defaultaccess指定默认的权限级别,如:defaultaccess search

3.2.4 采取什么样的匹配控制动作 在进行记录的匹配时,如果有多条规则存在,那么在第一次匹配产生后是否还进行后续的匹配或采取其它的动作将取决于此项的设置;控制方式共有以下三种: stop这个是默认值,这表示在一次匹配产生后将不再进行下一个匹配,所有后续的匹配将会停止。

continue无论匹配是否已经发生,继续进行直到所有的规则全部进行完匹配检查

break一个匹配发生后,跳出当前的子句进行后一个子句的检查 3.2.5 一个例子

access to dn.chilren=\指定“密码”属性

by self write #用户自己可更改

by * auth #所有访问者需要通过认证

by dn.children=\管理员组的用户可更改

参考资料:

http://blog.sina.com.cn/s/blog_61c2e5530100eonb.html (第一部分来源)

http://www.openldap.org/doc/admin24/access-control.html (网上英文文档) http://bbs.chinaunix.net/thread-926041-1-1.html (第三部分来源)

http://www.uvm.edu/~fcs/tools/ACLs.html (网上一个实际的大型例子) 联系我:shenzhen_lip@sina.com


openldap:用ACL控制访问权限 - 图文.doc 将本文的Word文档下载到电脑
搜索更多关于: openldap:用ACL控制访问权限 - 图文 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219