我在这样的LDAP中有一个搜索查询.这个查询究竟是什么意思?
("CN=Dev-India,OU=Distribution Groups,DC=gp,DC=gl,DC=google,DC=com");
Run Code Online (Sandbox Code Playgroud) 当我尝试使用CAS进行登录时,我看到了这种情况,这是通过LDAP对AD进行身份验证.
SEVERE: Servlet.service() for servlet cas threw exception
javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001E5, problem 2001 (NO_OBJECT), data 0, best match of:
''
]; remaining name '/'
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3092)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3013)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2820)
at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1829)
at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1752)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:338)
at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:257)
at org.springframework.ldap.core.LdapTemplate$3.executeSearch(LdapTemplate.java:231)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:293)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:237)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:588)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:546)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:401)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:421)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:441)
Run Code Online (Sandbox Code Playgroud)
到目前为止,我通过BindLdapAuthenticationHandler进行了身份验证,解析后,它生成了一个查询构建器,然后将其抛出.
我认为它在试图恢复属性时失败了.为什么remaining name '/'?
我有一个ldap服务器,我用它来验证tomcat Web应用程序中的用户.我正在使用JNDIRealm,它在上下文文件中配置,这很好用.
我还需要在ldap中搜索用户信息.我已经想出了如何使用"jndi方法"做到这一点,并且我通过使用哈希表创建自己的jndi上下文使其在tomcat之外正常工作.但是,我不想在代码中配置jndi属性,而是想在Realm配置旁边的上下文文件中创建一个JNDI Rsource.
我想我会做这样的事情:
<Resource
name="ldap"
auth="Container"
type="com.sun.jndi.ldap.LdapCtxFactory"
java.naming.factory.initial="com.sun.jndi.ldap.LdapCtxFactory"
java.naming.provider.url="ldap://localhost:389"
java.naming.security.authentication="simple"
java.naming.security.principal="uid=rjcarr,dc=example"
java.naming.security.credentials="abc123"
/>
Run Code Online (Sandbox Code Playgroud)
但是tomcat告诉我资源无法创建或者当我尝试用这样的东西初始化时:
Context initctx = new InitialContext();
DirContext ctx = (DirContext) initctx.lookup("java:comp/env/ldap");
Run Code Online (Sandbox Code Playgroud)
Tomcat告诉我"无法创建资源实例".我还在我的web.xml文件中添加了正确的resource-ref,所以我认为这不是问题所在.
由于LDAP与JNDI方法一起使用,我假设它应该能够配置为资源,对吧?我错过了什么?