兔八哥笔记10:WebLogic的内置LDAP控制访问语法

类别:Java 点击:0 评论:0 推荐:

兔八哥笔记10WebLogic的内置LDAP控制访问语法

 

 

    这几天在研究WebLogic Server 的LDAP Server的用法,Weblogic Server中有一个内置的LDAP Server,当然你也可以使用Weblogic Server集成第三方的LDAP Server,如Open LDAP、Netscape iPlanet, 微软的 Active Directory和 Novell NDS stores。

上述几个第三方的LDAP Server除了Open LDAP外都是商用软件,在Sun的网站上只提供了一个西班牙版的iPlanet使用版。因为我手头没有这些第三方的LDAP Server,所以这几天一直使用WLS内置的LDAP Server。

LDAP的中文资料极少,我只找到2篇翻译的文章,但并没有解决我的问题,于是这几天我每天都在读英文资料。我最终的目的是使用LDAP Server存储用户信息,然后能够通过JNDI控制它,到现在我初步实现了能够向内置的LDAP插入自定义的对象类的数据了。

你可能感觉这没什么了不起,的确是。但是如果你没有LDAP的知识而且没人指点的情况下在WLS中内置的LDAP Server中更改或插入数据,很可能你开始会很灰心!我这几天就是这样过来的。

这几天我遇到的问题如下:

1.  怎么能够看到内置LDAP Server的内容?使用LDAP Brower可以解决这个问题。

2.  怎样连接到内置的LDAP Server?这需要配置连接参数。

3.  怎样更改、添加、删除LDAP Server的 Attribute的值?这也是通过LDAP Brower来操作的,但要修改你当前连接用户操作LDAP的权限。当然也可以自己写程序完成。

4.  怎样定义一个objectClass对象,同时向这个对象添加自定义的属性,然后通过LDAP Brower或程序对它进行读写?通过LDAP Brower读写我已经找到操作办法了。

5.  怎样使用JNDI进行读写LDAP Server?这是我下周的工作内容。^_^。

我会在后续的笔记中说明这些问题的解决办法。

 

我感觉我应该把我这几天看过的东西和做过的东西拿出来给其他人分享一下,所以我先从这篇翻译的文章开始。

 

 

WLS的Acls.prop是控制LDAP 的用户的权限的。WLS的内置的LDAP Server的acls.prop的内容全部都注释起来了,所以当你通过LDAP Brower连接时,只能使用Admin来连接,而且不能修改任何属性。如果你想修改Entry的属性的值,那么你应该了解配置访问控制文件的语法。下面这篇文章说的就是这部分内容。

 

以下这部分是翻译的BEA的Weblogic的帮助。翻译这篇文章的时候我很是恼火,因为有很多长句子,而且开始时对于LDAP的基础知识也不熟悉,而国内还没有出版的关于LDAP的书籍,有些术语还没有统一的称呼,所以我建议,如果你在看我翻译的文章的时候感觉我在胡言乱语、并且很可能是在胡说八道的时候,那么建议你看一看原文,^_^。

 

原文位置:http://edocs.bea.com/wls/docs81/secmanage/ldap.html#1101845

原文版权归BEA公司所有。

 

       WebLogic的内置的LDAP Server支持IETF LDAP为LDAPv3制定的控制访问模型。下面这个片断将讲述在内置的LDAP Server中怎样实现控制访问。可以通过编辑访问控制文件来将这些规则直接应用到目录的入口。WebLogic中的访问控制文件是acls.prop。在Server的lib中可以找到这个文件。这个文件的所有访问控制规则都被注释掉了,如果想更改这些规则,你要手工更改这个文件。

注意:WebLogic Server内置的LDAP Server在默认的情况下只允许Admin帐号访问,WebLogic Server的security providers只使用Admin帐号访问内置的LDAP Server。如果你不想使用外部的LDAP Brower访问WebLogic Server的内置的LDAP Server,或者你只想使用Admin帐号访问内置的LDAP Server,你不需要编辑acls.prop文件,那么你可以跳过这一段(对于这篇笔记来说,你可以不用看了)。

 

访问控制文件(The Access Control File

访问控制文件(acls.prop)包含内置的LDAP Server的整个目录的完整的访问控制列表(ACL)。这个文件中的每一行都包含一个访问控制规则。一个访问控制规则由下面接个部分组成:

Ø         应用规则的LDAP目录的位置

Ø         应用规则的位置的范围

Ø         访问权限(grant或deny)

Ø         许可(grant或deny)

Ø         应用规则的属性(attribute)

Ø         允许或拒绝访问的主题(subject)

 

下面是一个访问控制文件的一个片断:

[root]|entry#grant:r,b,t#[all]#public

ou=Employees,dc=octetstring,dc=com|subtree#grant:r,c#[all]#public:
ou=Employees,dc=octetstring,dc=com|subtree#grant:b,t#[entry]#public:
ou=Employees,dc=octetstring,dc=com|subtree#deny:r,c#userpassword#public:
ou=Employees,dc=octetstring,dc=com|subtree#grant:r#userpassword#this:
ou=Employees,dc=octetstring,dc=com|subtree#grant:w,o#userpassword,title,
description,
postaladdress,telephonenumber#this:
cn=schema|entry#grant:r#[all]#public:

访问控制位置(Access Control Location)

       每个访问控制规则都应用于LDAP目录中的一个给定的位置。这个位置通常是一个区别命名(DN),但有一个例外,这就是[root],如果访问控制规则应用到整个目录,则只需要指定位置为[root]就可以了!

       如果被访问或更改的入口的位置与访问控制规则指定的位置不相等,或在访问控制规则指定的位置的下级,则这个访问控制规则将不会被执行。

 

访问控制范围(Access Control Scope

       访问控制范围有2种:

       Entry-一个Entry范围的访问控制列表只在下面的情况下被执行:

LDAP目录的入口的DN与访问控制规则指定的位置相同。这样的规则对于包含了比并行和副入口更敏感信息的单独入口非常有用。

      Subtree-意味着访问控制规则指定的位置及子树都可以适用这条规则。

      如果Entry与Subtree在访问控制规则中有冲突,则Entry要优先于Subtree。

访问权限(Access Rights

       访问权限应用于整个对象或对象的属性,有2个值:grant(准许)或deny(拒绝)。访问权限指定了LDAP操作的类型。

 

属性许可(Attribute Permissions

      

缩写及意义

说明

r Read

读. 如果granted, 允许属性何止包含在一个搜索操作中。

w Write

更改或添加. 如果granted, 允许属性何止包含在一个更改操作中。

o Obliterate

更改或删除. 如果granted, 允许属性何止包含在一个更改操作中。

s Search

搜索指定属性的入口. 如果granted, 允许属性和值包含在一个搜索操作中。

c Compare

比较属性值.如果granted,允许属性和值出现在比较操作中。

m Make

在当前入口下创建一个新入口的属性

当所有的属性都放在一个对象中,这个对象被创建时,m 是必需的。正像w 和 o 被用在更改操作中一样,m 被用在Add 操作中。

w 不负责Add 操作,m 不负责更改操作。

因为新对象还不存在,所以a 和 m 需要创建它,但必须grant给新对象的父类。

这不同于w 和 o,w 和 o 必须grant给正在被更改的对象。

因为m 同 w、o之间有很明显的区别,所以在添加一个子对象或入口时和更改一个子对象或入口时不会存在冲突。

为了在使用更改操作时能够成功替换值,用户必须同时拥有w和o的权限。

 

入口访问许可(Entry Permissions

       下面的许可应用于整个LDAP的访问。

缩写及意义

说明

a Add

在当前入口下添加一个入口, If granted, permits creation of an entry in the DIT subject to control on all attributes and values placed on the new entry at the time of creation. In order to add an entry, permission must also be granted to add at least the mandatory attributes.

d Delete

删除当前入口. If granted, permits the entry to be removed from the DIT regardless of controls on attributes within the entry.

e Export

将入口和所有的子入口导出到一个新位置。If granted, permits an entry and its sub entries (if any) to be exported; that is, removed from the current location and placed in a new location subject to the granting of suitable permission at the destination.

If the last RDN is changed, Rename permission is also required at the current location.

In order to export an entry or its subentries, there are no prerequisite permissions to the contained attributes, including the RDN attribute. This is true even when the operation causes new attribute values to be added or removed as the result of the changes to the RDN.

i Import

从指定位置导入入口及所有子入口及属性。If granted, permits an entry and its subentries (if any) to be imported; that is, removed from one other location and placed at the specified location (if suitable permissions for the new location are granted).

When importing an entry or its subentries, there are no prerequisite permissions for the contained attributes, including the RDN attributes. This is true even when the operation causes new attribute values to be added or removed as the result of the changes of RDN.

n RenameDN

改变一个LDAP入口的DN. Granting the Rename permission is necessary for an entry to be renamed with a new RDN, taking into account consequential changes to the DN of subentries. If the name of the superior entry is unchanged, the grant is sufficient.

When renaming an entry, there are no prerequisite permissions to contained attributes, including the RDN attributes. This is true even when the operation causes new attribute values to be added or removed as the result of the changes of RDN.

b BrowseDN

浏览一个入口的DN. If granted, permits entries to be accessed using directory operations that do not explicitly provide the name of the entry.

t ReturnDN

允许入口的DN作为一个操作的结果返回给客户端. If granted, allows the distinguished name of the entry to be disclosed in the operation result.

 

属性类型(Attributes Types

   [entry]意味着允许操作针对整个对象,比如删除对象或添加子对象,所以它的值只能是a、d、e、i、n、b、t。

    [all]应用范围为入口的所有属性, 所以它的值只能是r、w、o、s、c、m中的一个或多个。

    如果在ACL中关键字[all]和其他属性同时被指定,那么遵循属性指定的访问控制规则,因为[all]指定的规则不如属性指定的详细。

 

Subject类型(Subject Types

       访问控制规则可以和许多subject类型关联。访问控制规则的subject决定是否将访问控制规则应用到当前连接的Session上。

       下面是subject的类型:

§       AuthzID—应用于能够作为subject定义的一部分的一个单一用户。LDAP目录中的用户被定义为一个DN。

§       Group—应用于被指定为下列对象类的一组用户

· groupOfUniqueNames

· groupOfNames

· groupOfUniqueURLs

前2个类型包含用户列表,而最后一个类型允许用户包含在组中,这个组是自动建立在定义的标准上的。

§       Subtree—应用于作为subject和LDAP目录树中的子入口的部分的DN中。

§       IP Address—应用于指定的IP地址. 这种subject类型在下列情况下是很有用的:所有的访问都通过一个代理服务器或其他的服务器,只应用于一个指定的主机,而不是一个子网的范围。

§       Public—允许连接这个目录的任何人,而不管连接者是否经过授权。

§       This—应用于与被访问入口与用户的DN匹配的情况。

Grant/Deny 评估规则(Grant/Deny Evaluation Rules

       客户端发送一个访问入口信息的请求,LDAP Server允许或拒绝这个请求贺许多因素有关,如入口是否被保护,访问规则等。下面是一个说明:

(1)更详细的规则优先于其他规则。

    (2)如果不管规则的特殊情况,冲突仍然存在,subject规则将决定哪个规则被应用。优先级顺序从高到低为:IP Address-AuthzID或This-Group-Subtree或Public

    (3)当ACL存在冲突时,deny优先于grant

    (4)如果没有定义访问控制规则,deny是默认值,另外入口的访问规则要优先于该入口的Subtree的访问规则。

 

 

下面是WLS8.1自带的默认的acls.prop的内容:

# ACLs - for more info on ACL syntax, refer to the WebLogic Server System Administration

# Guide

#

# The default configuration is an empty file (nothing uncommented). This denies

# access to everyone except the Admin DN. Users may be able to bind, but can

# not read or modify entries in the LDAP server.

#

# If you wish to enable additional access, choose one of the following configurations,

# and uncomment the acl syntax by removing the '#'

#

# 7.0 Configuration - allows read access to everyone and write access to own user info

#

#[root]|entry#grant:s,r,b,t#[all]#public

#[root]|subtree#grant:s,r,c#[all]#public:

#[root]|subtree#grant:b,t#[entry]#public:

#[root]|subtree#deny:r,c#userpassword#public:

#[root]|subtree#deny:r,c#rootpw#public:

#[root]|subtree#deny:r,c#rootuser#public:

#[root]|subtree#grant:r#userpassword#this:

#[root]|subtree#grant:w,o#userpassword,title,description,postaladdress,telephonenumber#this:

#cn=schema|entry#grant:r,s#[all]#public:

#cn=schema|entry#grant:b,t#[entry]#public:

#

# Alternative configuration - user can see own information and update subset of

# attributes. No other access is allowed.

#

#[root]|subtree#grant:s,r,b,t#[all]#this:

#[root]|subtree#grant:w,o#userpassword,title,description,postaladdress,telephonenumber#this:

 

下面的这个文件是我修改的acls.prop,我把所有的权限都赋予了所有用户,使用我修改过的文件,所有的用户都都可以添加入口或属性,当然也包括子入口和属性。

# ACLs - for more info on ACL syntax, refer to the WebLogic Server System Administration

# Guide

#

# The default configuration is an empty file (nothing uncommented). This denies

# access to everyone except the Admin DN. Users may be able to bind, but can

# not read or modify entries in the LDAP server.

#

# If you wish to enable additional access, choose one of the following configurations,

# and uncomment the acl syntax by removing the '#'

#

# 7.0 Configuration - allows read access to everyone and write access to own user info

#

[root]|entry#grant:s,r,o,w,c,m#[all]#public

[root]|subtree#grant:s,r,o,w,c,m#[all]#public:

[root]|subtree#grant:a,d,e,i,n,b,t#[entry]#public:

#[root]|subtree#deny:r,w,o,c#userpassword#public:

#[root]|subtree#deny:r,w,o,c#rootpw#public:

#[root]|subtree#deny:r,w,o,c#rootuser#public:

#[root]|subtree#grant:r,w,o#userpassword#this:

#[root]|subtree#grant:w,o#userpassword,title,description,postaladdress,telephonenumber#this:

cn=schema|entry#grant:s,r,o,w,c,m#[all]#public:

cn=schema|entry#grant:a,d,e,i,n,b,t#[entry]#public:

#

# Alternative configuration - user can see own information and update subset of

# attributes. No other access is allowed.

#

#[root]|subtree#grant:s,w,r,b,o,t#[all]#this:

#[root]|subtree#grant:w,o#userpassword,title,description,postaladdress,telephonenumber#this:

 

 

                                                     兔八哥

                                               2003-12-2星期二 晚

本文地址:http://com.8s8s.com/it/it16924.htm