问题描述
- Weblogic Server 无法连接到 LDAP 或无法找到用户/组来执行角色映射。
- 内嵌的 LDAP 锁定问题。
- 与客户端身份验证相关的性能问题。
下面是六个常见的故障症状:
- Authentication Provider 无法连接到 LDAP。
- 用户无法验证身份。
- 用户可以验证身份,但 Authentication Provider 无法找到此用户所属的组。
- 用户可以验证身份,但没有所需的角色。
- 服务器因内嵌的 LDAP 锁定问题而无法启动。
- 对 LDAP 的客户端身份验证速度太慢。
|
故障排除
请注意,并非下面所有任务都需要完成。有些问题仅通过执行几项任务就可以解决。
快速链接
|
什么是
LDAP,WLS 如何使用它?
轻量型目录访问协议 (LDAP) 是程序用于从服务器中查找联系信息的一个协议。与关系数据库很相似,每个 ldap 数据库(或目录)都拥有一个
schema。LDAP schema 是作为一组对象类定义和属性定义来实现的。
LDAP 中使用的一些常用术语是:
- dc= 域组件
- o = 组织
- ou= 组织单位
- cn= 公用名
- dn= 辨别名
- uid= 用户 ID
当您需要在 LDAP 中搜索条目时,必须提供搜索的基准和过滤器。
例如:
ldapsearch .b "dc=beasys,dc=com" uid=fred
这将返回符合过滤器中所指定条件 uid=fred 的用户的所有属性。
uid=fred,ou=People,
dc=beasys,dc=com //
这就是所谓的“完整 DN”(Full DN)
objectClass=top
objectClass=person
objectClass=organizationalPerson
objectClass=inetorgperson
givenName=Fred
cn=Fred A
uid=fred
sn=A
creatorsName=uid=admin,ou=administrators,ou=topologymanagement,o=netscaperoot
modifiersName=uid=admin,ou=administrators,ou=topologymanagement,o=netscaperoot
createTimestamp=20040108160418Z
modifyTimestamp=20040108162837Z
此条目在 LDAP 树中的形式如下:
dc=beasys,dc=com
/ (root) \
/ \
/ \
ou=people
ou=otherusers
/
uid=fred
WLS 可以从外部目录服务器读取和搜索信息,这样就可以获得正确的配置信息,进行连接、绑定、搜索(基准和过滤器)等。
为此,您需要在 WLS 中配置下列字段:
- LDAP 服务器主机和端口
- 用于连接和进行搜索的用户/密码
- 用户基准 DN:在进行用户搜索时用作基准
- 用户过滤器:在进行用户搜索时用作过滤器
- 组基准 DN:在进行组搜索时用作基准
- 组过滤器:在进行组搜索时用作过滤器
- 组成员资格过滤器:在执行搜索以查找用户所属的组时用作过滤器
在这些字段内,您可以找到下列字符:
%u 将用用户 ID 替代
%g 将用组替代
%M 将用用户的完整 DN 替代
当 WLS 需要验证某个用户存在并拥有访问资源的权限/角色时,它使用所定义的 Principal 用户连接到 LDAP,然后对该用户进行搜索,确认其是否存在,并用其密码进行验证。然后,它搜索该用户所属的组。
下面是用于成员资格检查算法的一些简洁伪代码:
check_membership(group
g, principal p):
for each group
g1 that contains p directly:
if
g1 == g or check_membership(g, g1)
then
return success
return failure
一旦完成了上述步骤,WLS 将根据是允许访问还是拒绝访问,确认属于已找到的组的用户是否拥有访问所请求资源的权限/角色。
返回页首
WLS
中常用的 LDAP 服务器
WLS 中常用的 LDAP 服务器(作为 WLS 6.x 中的 LDAP 自定义 Realm 或较高 WLS 版本中的 Authentication
Provider)是:
- 缺省的 Authentication Provider(内嵌 LDAP) - 仅限于 WLS 7.x 和 WLS
8.x
- Iplanet
- Active Directory
- OpenLDAP
- Novell
返回页首
WLS
6.x、WLS 7.x 和 WLS 8.x 之间的差异
WLS 6.x
LDAP Realm 被定义为自定义 Realm,其 Realm 类名被设置为 weblogic.security.ldaprealmv2.LDAPRealm。配置数据包含连接、搜索等操作所需的所有数据,并且必须已定义了下列设置:
- server.host
- server.port
- server.principal
- user.filter
- user.dn
- group.filter
- group.dn
- membership.filter
然后,自定义 Realm 被映射到一个缓存 Realm 上,该缓存 Realm 反过来也被选择为服务器的缺省 Realm。
注意,在同一时间只有一个 Realm 是活动的。
WLS 尝试在启动时连接到 LDAP 服务器。如果您将 WebLogic Server 配置为使用自定义安全 Realm,而该
Realm 是不可用的,则 WebLogic Server 将不启动。在 6.1SP6 中引入了一个新的启动命令 -Dweblogic.security.RealmFailureOk=true,当该
Realm 不可用时,此命令将使服务器启动。此命令强制服务器使用 File Realm 来启动,而不是使用所配置的自定义 Realm。
WLS 7.x 和 WLS 8.x
WLS 7.x 和 WLS 8.x 拥有一个新的安全体系结构。 有关详细信息,请参阅: http://edocs/wls/docs70/secintro/realm_chap.html#1033368
如果您正在从 WLS 6.x 升级,那么 6.x 中定义的安全 Realm 将在兼容性范围内以相同的方式定义。
WLS 在启动时不会连接到 LDAP 服务器,除非它需要验证用于启动的用户身份。当 WLS 需要验证某个用户身份时,它打开一个
ldap 连接,这一点与 6.x 不同,在 6.x 中总是在启动时建立一个连接。
注意,可以有多个 Authentication Provider 处于活动状态。缺省的 LDAPRealm 是内嵌的 LDAP
Realm。
在 WLS 7.x / 8.x 安全模式下要定义 Authentication Provider,LDAP 服务器是 Authentication
Provider。下面的文件里定义了常见的 Authentication Provider:
%WL_HOME%\server\lib\mbeantypes\wlSecurityProviders.jar
您可以开发一个自定义Authentication Provider,并复制到 %WL_HOME%\server\lib\mbeantypes,或复制到启动时应在命令行标志中指定的另一个目录 -Dweblogic.typesDir=<dir>
中(8.1SP2 中新增)。
返回页首
排除连接故障
如果 Weblogic Server 无法连接到 LDAP 服务器,请验证以下条件:
您可以尝试使用 LDAP 浏览器连接。有关详细信息,请参阅 工具。
- LDAP 服务器的主机名定义正确,并且被运行 WLS 的计算机识别。
- 端口号正确(缺省值是 389,对于 SSL 是 636)。
- Principal 是 LDAP 中存在的一个用户,并且配置为用户的完整 DN,而不仅仅是用户 ID。Principal
可以类似于:
Principal="uid=admin, ou=Administrators, ou=TopologyManagement,
o=NetscapeRoot"
您可以使用 LDAP 浏览器验证用户的完整 DN。有关详细信息,请参阅 工具。
常见的连接错误代码是:
LDAP
error (49) - incorrect password (credentials)
LDAP error (32) - incorrect
principal (user)
有关 LDAP 结果代码的完整列表,请参阅 http://docs.sun.com/source/816-5608-10/log.htm#15324。
返回页首
排除用户身份验证故障
WLS 首先连接到 LDAP,然后根据在 Authentication Provider /自定义 Realm 中定义的用户基准
DN 和用户过滤器,尝试搜索用户。一旦找到该用户,它就会尝试用所提供的密码进行身份验证。
若要获得有关用户身份验证失败的确切位置的更多信息,可启用调试标志。
此搜索将类似于:
|
<SecurityDebug><getDNForUser
search ("ou=people,dc=beasys,dc=com", "(&(uid=fred)(objectclass=person))",
base DN & below)
|
<SecurityDebug><returnConnection
conn:netscape.ldap.LDAPConnection@e4bb3c> javax.security.auth.login.FailedLoginException:
[Security:090302]Authentication Failed: User fred denied
|
<SecurityDebug>
<DN for user fred: uid=fred,ou=People,dc=beasys,dc=com>
|
下列信息说明在 LDAP 中找到了用户,但在身份验证时失败:
|
<SecurityDebug>
<authenticate user:fred with DN:uid=fred,ou=People,dc=beasys,dc=com>
<Debug> <SecurityDebug> <authentication
failed 49>
|
排除组成员资格故障
在验证用户身份之后,就会对组进行一次搜索,以获得该用户所属组的列表,此列表可用于实现组和角色之间的角色映射。
这次搜索是使用在Authentication Provider中定义的“Static Group DNs from Member
DN Filter”(来自成员 DN 过滤器的静态组 DN)来完成的。
iPlanet 的示例:
(&(uniquemember=%M)(objectclass=groupofuniquenames))
可根据您的 LDAP 层次结构来更改此搜索。
用您正在各组中搜索的用户的完整 DN 代替 %M。
为了获得组成员资格失败的确切位置的更多信息,可启用调试标志。
如果该用户不属于任何组,或者如果搜索标准是无效的,您将会看到类似如下的调试信息:
|
<SecurityDebug>
<getDNForUser search("ou=people,dc=beasys,dc=com", "(&(uid=fred)(objectclass=person))",
base DN & below)>
<SecurityDebug> <DN for user fred: uid=fred,ou=People,
dc=beasys,dc=com>
<SecurityDebug> <search("ou=groups, dc=beasys,dc=com",
"(&(uniquemember=uid=fred,ou=People, dc=beasys,dc=com) (objectclass=groupofuniquenames))",
base DN & below)>
<SecurityDebug> <Result has more elements: false>
|
注意上面如何用用户的完整 DN 代替 %M。
返回页首
排除角色映射故障
在进行用户身份验证并找到组之后,WLS 将用户 + 组的列表与有权访问该资源的 Principal 用户进行比较,然后决定授予或拒绝访问权限。
在 WLS 7.x 和 WLS 8.x 中,执行对角色映射器的调用以获得用户/组拥有的角色,然后执行对 Authorization
Provider 的调用,从而授予或拒绝对所请求资源的访问权限。
如果存在多个 Authorization Provider,则由 Adjudicator 根据授权访问决策来决定是否授予或拒绝对所请求资源的访问权限。
若要获得有关角色映射失败的确切位置的更多信息,可启用调试标志。
下面是在 WLS 8.x 中对一个 Weblogic 用户进行调试输出的示例,该用户是 Admin 组的成员,但不拥有 Admin
角色,因此无权启动服务器:
|
<SecurityDebug>
<Default RoleMapper getRoles(): input arguments:
Subject: 2
Principal = class weblogic.security.principal.WLSUserImpl("weblogic")
Principal = class weblogic.security.principal.WLSGroupImpl("Admin")
Resource: type=<svr>,
application=, server=cgServer, action=boot>
<SecurityDebug> <Default RoleMapper getRoles(): returning
roles: Anonymous>
<SecurityDebug> <RoleManager.getRoles Subject:
Subject: 2
Principal = class weblogic.security.principal.WLSUserImpl("weblogic")
Principal = class weblogic.security.principal.WLSGroupImpl("Admin")
Resource: <svr> type=<svr>,
application=, server=cgServer, action=boot Anonymous roles.>
<SecurityDebug> <Default Authorization isAccessAllowed():
input arguments:>
<SecurityDebug> < Subject: 2
Principal = class weblogic.security.principal.WLSUserImpl("weblogic")
Principal = class weblogic.security.principal.WLSGroupImpl("Admin")
<SecurityDebug> <Roles:Anonymous>
<SecurityDebug> <Resource: type=<svr>, application=,
server=cgServer, action=boot>
<SecurityDebug> <Direction: ONCE>
<SecurityDebug> <Context Handler: >
<SecurityDebug> <null>
<SecurityDebug> <Default Authorization isAccessAllowed():
returning DENY>
|
如何获得配置数据
WLS 6.x
在 WLS 6.x 中,自定义安全 Realm 的配置信息保存到 config.xml
中。
WLS 7.x
在 WLS 7.x 中,Authentication Provider 配置并未在 config.xml 中定义。该信息以二进制格式保存在
domain_name\userConfig\Security
目录中。
若要获得配置信息,可在使用 setEnv.cmd/sh
设置环境后,在域目录中执行下列命令:
java weblogic.management.commo.WebLogicMBeanDumper
-includeDefaults -name Security:* output-file
此操作将会创建一个 xml 格式输出文件,其中将包含与 WLS 7.x 中的安全性相关的所有配置数据。
有关此命令的详细信息,请参阅:http://e-docsbea.com/wls/docs70/admin_domain/failures.html#1110150
WLS 8.x
在 WLS 8.x 中,Authentication Provider 的配置保存在 config.xml
中。
返回页首
什么是
Authentication Provider 中的控制标志?
在 WLS 7.x 和 WLS 8.x 中,可以配置多个 Authentication Provider。您必须使用 Authenticator-->General
选项卡上的 JAAS Control Flag 属性来控制在登录序列中如何使用 Authentication Provider。
控制标志可取下面这些值之一:
- REQUIRED - 总是调用 Authentication Provider,并且用户必须始终通过其身份验证测试。
- SUFFICIENT - 如果用户通过了此 Authentication Provider 的身份验证测试,则不再执行其它
Authentication Provider(JAAS Control Flag 设置为 REQUIRED 的 Authentication
Provider 除外),因为已对该用户进行了充分的身份验证。
- REQUISITE - 如果用户通过了此 Authentication Provider 的身份验证测试,执行其它
Authentication Provider 但可能会失败(JAAS Control Flag 设置为 REQUIRED
的 Authentication Provider 除外)。
- OPTIONAL - 允许该用户通过这些 Authentication Provider 的身份验证测试,但是,如果在安全
Realm 中配置的所有 Authentication Provider 都将 JAAS Control Flag
设置为 OPTIONAL,则该用户必须通过其中一个 Authentication Provider 的身份验证测试。
备注:在创建安全 Provider 时,WebLogic Server 管理控制台实际上将 JAAS Control Flag
设置为 OPTIONAL。安全提供程序的 MBean 实际上缺省为 REQUIRED。
返回页首
在控制台中列举用户/组
如果 ldap 中有过多的用户/组,并且从控制台中访问它们时服务器挂起或需要很多时间,则可以进行如下设置来禁止列举所有用户/组:
EnumerationAllowed="false"
(在 config.xml
的 <Realm>
标记上)。
备注:这只是针对用于 WLS 6.x 和 WLS 7.x 兼容模式的最新 Service Pack。对于 WLS 8.x,要确保至少拥有
SP2,因为在 SP2 中修正了一些问题。
性能问题
用户身份验证的当前行为如下:
- 在验证用户身份之后,确定组成员资格。
- 将用户所属的组确定作为一个列表。然后对于此列表中的每个组,查找该组所属的所有组。
- 这一过程递归执行,直到某个组不再属于其它组。
例如,如果用户 U1 属于组 G1 和 G2,而组 G1 属于 G3,那么用户 U1 属于 G1、G2 和 G3。
为 U1 确定组成员资格 - 获得 G1 和 G2,然后为 G1 确定组关系(获得 G3),然后为 G2 确定组关系(无结果)。
这种递归搜索可能存在性能问题,特别是在 LDAP 中存在很多组的时候。
为了避免这种性能问题,可以配置两个参数:
- GroupMembershipSearching
- MaxGroupMembershipSearchLevel
GroupMembershipSearching
此属性控制组搜索的深度是有限还是无限。缺省值是无限次搜索。如果配置了有限次搜索,则
MaxGroupMembershipSearchLevel
属性指定该限值。如果配置了无限次搜索,则忽略 MaxGroupMembershipSearchLevel。
MaxGroupMembershipSearchLevel
如果已将 GroupMembershipSearching
属性设置为有限制,则此属性控制组成员资格搜索的深度。否则忽略此属性。缺省值是“0”(数字零)。
返回页首
内嵌的
LDAP 问题
在 domain/server/ldap/ldapfiles
文件夹下创建了一个名为 embeddedldap.lok
的文件。
如果该文件存在,则服务器不能启动,并将看到下列错误:
|
<Emergency>
<WebLogicServer> <BEA-000342>
<Unable to initialize the server: weblogic.server.ServiceFailureException:
Could not obtain an exclusive lock to the embedded LDAP data files
directory:
./server1/ldap/ldapfiles because another WebLogic Server is already
using this directory. Ensure that the first WebLogic Server is
completely shutdown and restart the server.>
|
为避免此错误,应确保没有没有启动其它进程或访问此文件并将它删除。
在关机时通常会对此文件进行解锁,但如果上次发生了异常关机(如崩溃),则可能未正确解锁此文件,从而在下次启动时产生此类错误。
返回页首
调试标志
在 WLS 6.x 中,在 config.xml
的 ServerDebug
标记下,添加下列信息以设置调试标志:
<ServerDebug
DebugSecurityRealm="true" Name="myserver"/>
在 WLS 7.x 和 WLS 8.x 中,在 config.xml
的 ServerDebug
标记下,添加下列信息以设置调试标志。服务器重新启动后将考虑这些标志:
<ServerDebug
DebugSecurityAdjudicator="true" // for security
adjudicator debug
DebugSecurityAtn="true" // for security
authentication debug
DebugSecurityAtz="true" // for
security authorization debug
DebugSecurityRoleMap="true" // for
security role mapping debug
Name="MyServer"/>
也可以通过命令行,用 weblogic.Admin
SET 命令来设置 ServerDebugMBean。注意,尽管调试属性的变化值将反映在
ServerDebugMBean
状态中,但在重新启动 Admin 服务器之前将不再产生输出。
下例说明如何使用命令行界面动态地启用 DebugSecurityAtz
调试属性:
java weblogic.Admin -url t3://host:port -username
adminuser -password adminpwd SET -type ServerDebug -property
DebugSecurityAtz true
此命令将在配置中设置所有服务器实例上的 DebugSecurityAtz
调试属性。
通过检查 config.xml
中的 StdoutDebugEnabled
被设置为“true”,确保已启用调试到 stdout
选项。可以通过控制台或命令行来启用调试到 stdout
选项:
-Dweblogic.StdoutDebugEnabled=true
调试信息将被记录到服务器日志以及标准输出中。
在 WLS 8.1 中,服务器日志文件在启动时用 BEA-161519 消息进行指定:
BEA-161519 Notice: The server log file fileName
is opened. All server side log events will be written to this
file.
或者在 WLS 7.x 中通过以下消息来指定:
FileLogger Opened at fileName.
返回页首
工具
LDAP 浏览器
LDAP 浏览器可用于访问内嵌 LDAP 或其它任何 LDAP。您可以从网址 http://www.iit.edu/~gawojar/ldap/
下载此工具。
若要确认您的 LDAP 服务器已启动并正在运行,可以尝试用此 LDAP 浏览器连接到该服务器和端口号。
单击“Fetch DNs”将显示 LDAP 服务器上的所有可用根基准 DN:
|
正如在文件系统内用文件路径来唯一标识文件一样,在目录树内用辨别名
(DN) 来唯一标识目录条目。DN 通过用一系列以逗号分隔的属性和属性值来标识条目。但是,DN 的路径规范与传统的文件系统的顺序相反。也就是说,文件系统一般用最右边的分量中指定的文件的实际名称来从左至右跟踪通向文件的路径,而
DN 指定最左边的分量作为实际目录对象,最右边的值作为目录根点。
ldapsearch 命令
搜索用户的另一个方法是使用 ldapsearch 命令,例如:
ldapsearch b "dc=beasys,dc=com" uid=fred
有关此命令和使用方法的详细信息,请参阅 http://docs.sun.com/source/816-5608-10/utilities.htm#2019555。
返回页首
|
Authentication Provider 的示例
IPlanet 身份验证程序示例
<weblogic.security.providers.authentication.IPlanetAuthenticator
ControlFlag="SUFFICIENT"
Credential="{3DES}eFlqRhsYDyU5sqpnDRzCjg=="
DynamicGroupNameAttribute="cn"
DynamicGroupObjectClass="groupofURLs"
DynamicMemberURLAttribute="memberURL"
GroupBaseDN="ou=groups, dc=example,dc=com"
GroupFromNameFilter="(|(&(cn=%g)(objectclass=groupofUniqueNames))(&(cn=%g)(objectclass=groupOfURLs)))"
Host="HOST IP or NAME OF LDAP"
Name="Security:Name=myrealmIPlanetAuthenticator"
Port="the port number of LDAP"
Principal="uid=admin, ou=Administrators, ou=TopologyManagement,
o=NetscapeRoot"
Realm="Security:Name=myrealm"
StaticGroupDNsfromMemberDNFilter="(&(uniquemember=%M)(objectclass=groupofuniquenames))"
StaticGroupNameAttribute="cn"
StaticGroupObjectClass="groupofuniquenames"
StaticMemberDNAttribute="member"
UserBaseDN="ou=people,dc=example,dc=com"
UserFromNameFilter="(&(uid=%u)(objectclass=person))"
UserNameAttribute="uid"
UserObjectClass="person"/>
Active
Directory 身份验证程序示例
<weblogic.security.providers.authentication.ActiveDirectoryAuthenticator
ControlFlag="SUFFICIENT" Credential="{3DES}96Kl0euDFQQ="
GroupBaseDN="CN=Users,DC=supportLDAP,DC=example,DC=com"
GroupFromNameFilter="(&(cn=%g)(objectclass=group))"
Host=" HOST IP or NAME OF LDAP"
Name="Security:Name=myrealmActiveDirectoryAuthenticator"
Principal="CN=Administrator,CN=Users,DC=supportLDAP,DC=example,DC=com
Realm="Security:Name=myrealm"
StaticGroupDNsfromMemberDNFilter="(&(member=%M)(objectclass=group))"
StaticGroupNameAttribute="cn"
StaticGroupObjectClass="group"
StaticMemberDNAttribute="member"
UserBaseDN="CN=Users,DC=supportLDAP,DC=example,DC=com"
UserFromNameFilter="(&(cn=%u)(objectclass=user))"
UserNameAttribute="cn" UserObjectClass="user"/>
OpenLDAP
身份验证程序示例
<weblogic.security.providers.authentication.OpenLDAPAuthenticator
ControlFlag="SUFFICIENT" Credential="{3DES}96Kl0euDFQQ="
GroupBaseDN="ou=groups, dc=example, dc=com"
GroupFromNameFilter="(&(cn=%g)(objectclass=groupofnames))"
Name="Security:Name=myrealmOpenLDAPAuthenticator"
Principal="cn=Directory Manager,dc=example,dc=com"
Realm="Security:Name=myrealm"
StaticGroupDNsfromMemberDNFilter="(&(member=%M)(objectclass=groupofnames))"
StaticGroupNameAttribute="cn"
StaticGroupObjectClass="groupofnames"
StaticMemberDNAttribute="member"
UserBaseDN="ou=people, dc=example, dc=com"
UserFromNameFilter="(&(cn=%u)(objectclass=person))"
UserNameAttribute="cn" UserObjectClass="person"/>
|
|
反馈
请给我们提供您的意见,说明此支持诊断模式“LDAP 问题”一文是否有所帮助,您需要的任何解释,以及对支持诊断模式的新主题的任何要求。
|
|
免责声明:
依据 BEA 与您签署的维护和支持协议条款,BEA Systems, Inc. 在本网站上提供技术技巧和修补程序供您使用。虽然您可以将这些信息和代码与您获得
BEA 授权的软件一起使用,但 BEA 并不对所提供的技术技巧和修补程序做任何形式的担保,无论是明确的还是隐含的。
本文档中引用的任何商标是其各自所有者的财产。有关完整的商标信息,请参考您的产品手册。
|
|