オープンソースのLDAPプラグイン(code.google.com/p/nexus-ldap/)でNexusリポジトリマネージャー(nexus.sonatype.org)を使用していますが、間違ったプロトコルバージョンが使用されていることを示すエラーが表示されます(詳細は以下を参照)。 。プラグインが行うのは、JNDILDAPサービスプロバイダーを使用してLDAPサーバーに接続することだけです。nexus.logファイルのスタックトレースを見ると、JNDILDAP実装でのコンテキストの初期化中に例外が発生します。したがって、以下で説明する問題は、Nexusプラグインではなく、JNDIの誤用またはLDAP認証の誤解が原因であると推測されます。
これがどのようにエラーが発生するかについての推測やアイデアは大歓迎です!
問題を再現する手順は何ですか?
- OpenLDAP 1.2.xサーバーを使用してLdapAuthenticatingRealmを使用するようにNexusを構成します。そのため、LDAPプロトコルのバージョン2です。
- OpenLDAPサーバーからユーザーを一覧表示し、Nexus構成UIのロールにマッピングしてみてください-完全に機能します。
- 次に、ロールに正常にマップされたLDAPユーザーを使用して、実行中のNexusインスタンスにログインするか認証を試みます。
期待される出力はどれくらいですか?代わりに何が見えますか?
ログインしようとすると、「ユーザー名、パスワードが正しくないか、Nexusユーザーインターフェイスを使用する権限がありません。再試行してください。」というエラーメッセージが表示されます。Nexusログファイルには、SunによるJNDI-LDAP実装(以下のログファイルから取得したスタックトレースを参照)がLDAPサーバーに対してユーザーを認証するために、指定された情報でコンテキストを初期化しようとしたときにスローされる例外が表示されます。Nexus UIを使用したユーザールックアップは、認証中に実行されるルックアップと同様に正常に機能します(以下のログファイルを参照)。
CommunicationExceptionに含まれるエラーメッセージ( "[LDAP:エラーコード2-バージョンはサポートされていません]")は、誤ったLDAPプロトコルバージョンの使用を示しています。OpenLDAPバージョン1.2.7-30はLDAPv2のみをサポートしているため(企業環境-サーバーバージョンはネゴシエートできません)、プロトコルバージョン2を明示的に使用しようとしました。これを行うには、ソースコードをチェックアウトし、「env.put( "java.naming.ldap.version"、 "2");」という行を追加します。se.devoteam.nexus.ldap.NexusLdapContextFactory:52に。何も変わっていません。
テスト中に、Sunのソースコードを参照しているときに、javax.naming.ldap.InitialLdapContext.InitialLdapContext()メソッドが最初に行うことは、LDAPプロトコルのバージョンを「3」(javax.naming.ldap.InitialLdapContext:131)に設定することであることに気付きました。 )。Java6-documentationはプロパティ(java.sun [dot] com / javase / 6 / docs / technotes / guides / jndi / jndi-ldap-gl.html#version)を説明していますが、JNDI-tutorialはこれをプロトコルバージョンの競合を解決する適切な方法(java.sun [dot] com / products / jndi / tutorial / ldap / misc / version.html)疑問に思う:JNDIを使用するときにLDAPプロトコルバージョン2を明示的に使用する方法はありますか? LDAPサービスプロバイダーとして?
次に、かなり最新バージョンのOpenLDAPサーバー(openldap2-2.3)を、古いサーバーに委任するLDAPプロトコルバージョン3要求のプロキシとして使用してみました。同じ問題、同じ例外。
追加情報
環境:Tomcat6.0.16にデプロイされたNexusWebappバージョン:1.3.6 ldap-realmバージョン:0.4 JREバージョン:JDK 1.6.0_14-b08プラットフォーム:仮想環境LDAPディレクトリブランド:OpenLDAP1.2.7および2.2.3
nexus.logの関連部分:
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - o.s.j.r.PlexusSecur~ - Realm: 'org.sonatype.jsecurity.realms.XmlAuthenticatingRealm', caused: User 'testuser' cannot be retrieved.
org.jsecurity.authc.AccountException: User 'testuser' cannot be retrieved.
at org.sonatype.jsecurity.realms.XmlAuthenticatingRealm.doGetAuthenticationInfo(XmlAuthenticatingRealm.java:68)
at org.jsecurity.realm.AuthenticatingRealm.getAuthenticationInfo(AuthenticatingRealm.java:168)
at org.sonatype.jsecurity.web.WebPlexusSecurity.getAuthenticationInfo(WebPlexusSecurity.java:185)
at org.jsecurity.authc.pam.ModularRealmAuthenticator.doSingleRealmAuthentication(ModularRealmAuthenticator.java:186)
at org.jsecurity.authc.pam.ModularRealmAuthenticator.doAuthenticate(ModularRealmAuthenticator.java:276)
at org.jsecurity.authc.AbstractAuthenticator.authenticate(AbstractAuthenticator.java:141)
at org.jsecurity.mgt.AuthenticatingSecurityManager.authenticate(AuthenticatingSecurityManager.java:171)
at org.jsecurity.mgt.DefaultSecurityManager.login(DefaultSecurityManager.java:312)
at org.jsecurity.subject.DelegatingSubject.login(DelegatingSubject.java:237)
at org.jsecurity.web.filter.authc.AuthenticatingFilter.executeLogin(AuthenticatingFilter.java:49)
at org.sonatype.nexus.security.filter.authc.NexusHttpAuthenticationFilter.onAccessDenied(NexusHttpAuthenticationFilter.java:121)
at org.jsecurity.web.filter.AccessControlFilter.onPreHandle(AccessControlFilter.java:145)
at org.jsecurity.web.filter.PathMatchingFilter.preHandle(PathMatchingFilter.java:175)
at org.jsecurity.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:129)
at org.jsecurity.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:180)
at org.jsecurity.web.servlet.FilterChainWrapper.doFilter(FilterChainWrapper.java:57)
at org.jsecurity.web.servlet.JSecurityFilter.doFilterInternal(JSecurityFilter.java:382)
at org.jsecurity.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:180)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:419)
at org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:378)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1509)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.sonatype.jsecurity.realms.tools.NoSuchUserException: User with id='testuser' not found!
at org.sonatype.jsecurity.realms.tools.DefaultConfigurationManager.readUser(DefaultConfigurationManager.java:410)
at org.sonatype.jsecurity.realms.tools.ResourceMergingConfigurationManager.readUser(ResourceMergingConfigurationManager.java:278)
at org.sonatype.jsecurity.realms.XmlAuthenticatingRealm.doGetAuthenticationInfo(XmlAuthenticatingRealm.java:64)
... 29 more
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.LdapAuthent~ - Authenticating user 'testuser' through LDAP
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.LdapAuthent~ - LDAP user search filter: (&(objectClass=account)(uid={0}))
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.NexusLdapCo~ - LDAP security principal not set
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.NexusLdapCo~ - LDAP security credentials not set
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.NexusLdapCo~ - LDAP provider url(s): ldap://ldap:389
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.NexusLdapCo~ - LDAP initial context factory: com.sun.jndi.ldap.LdapCtxFactory
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.NexusLdapCo~ - LDAP security protocol: null
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.NexusLdapCo~ - LDAP security authentication: null
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.NexusLdapCo~ - LDAP search scope: subtree
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.LdapAuthent~ - User object found
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.LdapAuthent~ - LDAP authentication principal: uid=testuser, dc=corporation,dc=de
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.NexusLdapCo~ - LDAP provider url(s): ldap://ldap:389
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.NexusLdapCo~ - LDAP initial context factory: com.sun.jndi.ldap.LdapCtxFactory
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.NexusLdapCo~ - LDAP security protocol: null
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - s.d.n.l.NexusLdapCo~ - LDAP security authentication: null
2009-10-23 15:06:37 ERROR [ajp-8009-3 ] - o.j.r.l.AbstractLda~ - LDAP naming error while attempting to authenticate user.
javax.naming.CommunicationException: [LDAP: error code 2 - version not supported]
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3089)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2987)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2789)
at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2703)
at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:293)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:134)
at se.devoteam.nexus.ldap.NexusLdapContextFactory.getLdapContext(NexusLdapContextFactory.java:63)
at se.devoteam.nexus.ldap.LdapAuthenticatingRealm.queryForAuthenticationInfo(LdapAuthenticatingRealm.java:139)
at org.jsecurity.realm.ldap.AbstractLdapRealm.doGetAuthenticationInfo(AbstractLdapRealm.java:186)
at org.jsecurity.realm.AuthenticatingRealm.getAuthenticationInfo(AuthenticatingRealm.java:168)
at org.sonatype.jsecurity.web.WebPlexusSecurity.getAuthenticationInfo(WebPlexusSecurity.java:185)
at org.jsecurity.authc.pam.ModularRealmAuthenticator.doSingleRealmAuthentication(ModularRealmAuthenticator.java:186)
at org.jsecurity.authc.pam.ModularRealmAuthenticator.doAuthenticate(ModularRealmAuthenticator.java:276)
at org.jsecurity.authc.AbstractAuthenticator.authenticate(AbstractAuthenticator.java:141)
at org.jsecurity.mgt.AuthenticatingSecurityManager.authenticate(AuthenticatingSecurityManager.java:171)
at org.jsecurity.mgt.DefaultSecurityManager.login(DefaultSecurityManager.java:312)
at org.jsecurity.subject.DelegatingSubject.login(DelegatingSubject.java:237)
at org.jsecurity.web.filter.authc.AuthenticatingFilter.executeLogin(AuthenticatingFilter.java:49)
at org.sonatype.nexus.security.filter.authc.NexusHttpAuthenticationFilter.onAccessDenied(NexusHttpAuthenticationFilter.java:121)
at org.jsecurity.web.filter.AccessControlFilter.onPreHandle(AccessControlFilter.java:145)
at org.jsecurity.web.filter.PathMatchingFilter.preHandle(PathMatchingFilter.java:175)
at org.jsecurity.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:129)
at org.jsecurity.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:180)
at org.jsecurity.web.servlet.FilterChainWrapper.doFilter(FilterChainWrapper.java:57)
at org.jsecurity.web.servlet.JSecurityFilter.doFilterInternal(JSecurityFilter.java:382)
at org.jsecurity.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:180)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:419)
at org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:378)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1509)
at java.lang.Thread.run(Thread.java:619)
2009-10-23 15:06:37 INFO [ajp-8009-3 ] - o.s.n.s.f.a.NexusSe~ - Unable to authenticate user [testuser] from address/host [172.31.2.155/172.31.2.155]
2009-10-23 15:06:37 DEBUG [ajp-8009-3 ] - o.s.n.e.Authenticat~:default - Notifying 1 EventListener about event org.sonatype.nexus.auth.NexusAuthenticationEvent fired (org.sonatype.nexus.auth.NexusAuthenticationEvent@d637d)