http://www.bea.com.cn/support_pattern/LDAP_Issues_Pattern.html 問題描述
|
故障排除 請注意,并非下面所有任務都需要完成。有些問題僅通過執行幾項任務就可以解決。 快速鏈接 |
什么是 LDAP,WLS 如何使用它? 輕量型目錄訪問協議 (LDAP) 是程序用于從服務器中查找聯系信息的一個協議。與關系數據庫很相似,每個 ldap 數據庫(或目錄)都擁有一個 schema。LDAP schema 是作為一組對象類定義和屬性定義來實現的。 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 中配置下列字段:
%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)是:
WLS 6.x、WLS 7.x 和 WLS 8.x 之間的差異 WLS 6.x LDAP Realm 被定義為自定義 Realm,其 Realm 類名被設置為 weblogic.security.ldaprealmv2.LDAPRealm。配置數據包含連接、搜索等操作所需的所有數據,并且必須已定義了下列設置:
注意,在同一時間只有一個 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 瀏覽器連接。有關詳細信息,請參閱工具。
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。 控制標志可取下面這些值之一:
返回頁首 在控制臺中列舉用戶/組 如果 ldap 中有過多的用戶/組,并且從控制臺中訪問它們時服務器掛起或需要很多時間,則可以進行如下設置來禁止列舉所有用戶/組: EnumerationAllowed="false" (在 config.xml 的 <Realm> 標記上)。 備注:這只是針對用于 WLS 6.x 和 WLS 7.x 兼容模式的最新 Service Pack。對于 WLS 8.x,要確保至少擁有 SP2,因為在 SP2 中修正了一些問題。 性能問題 用戶身份驗證的當前行為如下:
為 U1 確定組成員資格 - 獲得 G1 和 G2,然后為 G1 確定組關系(獲得 G3),然后為 G2 確定組關系(無結果)。 這種遞歸搜索可能存在性能問題,特別是在 LDAP 中存在很多組的時候。 為了避免這種性能問題,可以配置兩個參數:
此屬性控制組搜索的深度是有限還是無限。缺省值是無限次搜索。如果配置了有限次搜索,則 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: |


一旦連接后,您就可以看到 LDAP 樹: |

正如在文件系統內用文件路徑來唯一標識文件一樣,在目錄樹內用辨別名 (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。 返回頁首 |
是否需要更多幫助? 如果您已經理解這個模式,但仍需要其它幫助,您可以:
|
反饋 請給我們提供您的意見,說明此支持診斷模式“LDAP 問題”一文是否有所幫助,您需要的任何解釋,以及對支持診斷模式的新主題的任何要求。 |
免責聲明: 依據 BEA 與您簽署的維護和支持協議條款,BEA Systems, Inc. 在本網站上提供技術技巧和修補程序供您使用。雖然您可以將這些信息和代碼與您獲得 BEA 授權的軟件一起使用,但 BEA 并不對所提供的技術技巧和修補程序做任何形式的擔保,無論是明確的還是隱含的。 本文檔中引用的任何商標是其各自所有者的財產。有關完整的商標信息,請參考您的產品手冊。 |