ldap数据库--ODSEE--ACI

查看跟DN下的aci

  ldapsearch -h hostname -p port -D "cn=Directory Manager" -w - -b "BASE_DN" "(objectclass=*)" aci

Aci语法:

  aci: [list of (target)](version 3.0; acl "name";[list of "permission bindRules;"])

  参数说明:   

    target:可以使条目,属性,多个条目或者属性,可以通过filter进行匹配的条目和属性。该属性可选,如果没有指定,则针对子树(subtree)下所有条目。

    name:用于却分每个aci唯一标识,但是对名字没有限制。尽量保持aci名字的唯一性,不要重复。当不能确定aci是否生效可以通过Get Effective Rights查看,这时aci的名字就起作用了。

    permission:aci对应的可操作权限

    bindRules:指定那些条目具有使用该aci。

Aci targets语法

  (keyword = " expression")

  Keyword :可以使如下:target ,tartetattr,targetfilter,targettrfilters,targetscope
  expression:可以使用“=”和“!=” 但是当keyword是targettrfilters和targetscope时不能使用"!="
例如:
  (target = "ldap:///uid=bjensen,ou=People,dc=example,dc=com") :目标条目为uid=bjensen的条目的所有属性,
    使用如下filter均可匹配该条目
  (target= "ldap:///uid=bj*,ou=people,dc=example,dc=com")
  (target= "ldap:///uid=*,ou=people,dc=example,dc=com") 
  (target= "ldap:///*,ou=people,dc=example,dc=com")
  (target= "ldap:///uid=bjensen,*,dc=com")
  (target= "ldap:///uid=bjensen*")

Aci targetattr语法
  (targetattr = "attribute") or (targetattr != "attribute")
  如果targetattr没有出现则表示不匹配任何属性;如果要匹配所有属性需写:targetattr="*"
  匹配多个属性书写规则如下:
  (targetattr = "attribute1 || attribute2|| ... attributeN")
Aci targetfilter语法
  根据filter来搜索所有匹配的条目:(targetfilter = "(standard LDAP search filter)")
  例如:
  (targetfilter = "(|(status=contractor)(fulltime<=79))") :status=contractor并且filltime小于等于79的条目
Aci targattrfilters语法
  指定哪些属性的值可以被添加,删除,修改:(targattrfilters="add=attr1:F1 && attr2:F2... && attrn:Fn, del=attr1:F1 && attr2:F2 ... && attrn:Fn")
  参数说明:
  add
    添加属性值
  del
    删除属性值
  attrn
    替换或更新属性值
  Fn
    仅对关联的属性生效
Aci targetscope语法
  (targetscope="base")

  base
    aci仅作用于目标资源
  onelevel
    aci仅作用于目标资源和他的第一个子树
  subtree
    aci作用于目标资源和所有子树
  如果targetscope关键字没有指定,默认值为subtree。
Aci rights
  read ,write,add,delete,search,compare,selfwrite,proxy,import,export,All

Aci 示例 

  1)允许匿名访问除userPassword之外的所有条目的属性:

    aci: (targetattr !="userPassword")(version 3.0; acl "Anonymous example"; allow (read, search, compare)userdn= "ldap:///anyone" ;)

  2) 允许自己修改自己的部分属性:

    aci: (targetattr="homePhone || homePostalAddress")(version 3.0; acl "Write Example.com"; allow (write) userdn="ldap:///self" ;)

  3)允许cn=HRGroup的组访问所有ou=People,dc=example,dc=cr下的所有条目(假设aci在ou=People,dc=example,dc=cr下):

    aci: (targetattr="*") (version 3.0; acl "HR"; allow (all)  groupdn= "ldap:///cn=HRgroup,ou=Groups,dc=example,dc=com";)

  4)允许ou=People下任何用户在ou=Social Committee,dc=example,dc=com下添加组(可以自己的需求更改objectClass对应的类,达到添加动态组和静态组):

    aci: (targetattr="*") (targattrfilters="add=objectClass:(|(objectClass=groupOfNames)(objectClass=top))")(version 3.0; acl "Create Group"; allow (read,search,add) userdn= "ldap:///uid=*,ou=People,dc=example,dc=com") and dns="*.Example.com";)

    从aci的权限可以看出,词条aci并没有赋予用户修改权限,即只能添加,不能修改

  5)允许组管理员修改,删除组操作ou=Social Committee,dc=example,dc=com下的组,假设该条aci在ou=Social Committee,dc=example,dc=com下:

    aci: (targetattr = "*") (targattrfilters="del=objectClass:(objectClass=groupOfNames)") (version 3.0; acl "Delete Group"; allow (write,delete) userattr="owner#GROUPDN";)

  6)允许用户自己修改自己的member属性,假设该aci添加在ou=Social Committee,dc=example,dc=com条目下:

    aci: (targettattr="member")(version 3.0; acl "Group Members"; allow (selfwrite) (userdn= "ldap:///uid=*,ou=People,dc=example,dc=com") ;)

  可以根据自己的需要做适当调整,来满足对用户权限的控制。

查看aci是否生效

  当完成一个aci的定义并把aci添加到对应的作用范围后,如果不确定aci是否生效可以使用view effective rights,使用ldapsearch命令可以查看对应的作用域下的所有条目该aci是否生效,操作命令如下:

  ldapsearch -J "1.3.6.1.4.1.42.2.27.9.5.2" -h host1.Example.com -p 389 -D "uid=Directory Manager" -w - -b "dc=example,dc=com" "(objectclass=*)" aclRights

  参数说明:  

    -J:默认值

    -D:使用搜索绑定的用户

    -b:base DN

  搜索结果类似如下:如果用户对条目没有操作权限,则不会显示出来。  

  dn: dc=example,dc=com
  aclRights;entryLevel: add:0,delete:0,read:1,write:0,proxy:0
  dn: ou=Groups, dc=example,dc=com
  aclRights;entryLevel: add:0,delete:0,read:1,write:0,proxy:0

  如果通中类型的aci较多,也可以使用宏匹配的方式进行。具体可以参考:docs.oracle.com/cd/E29127_01/doc.111170/e28972/ds-access-control.htm

  

  


 
原文地址:https://www.cnblogs.com/adam1991/p/7651646.html