开发者

LDAP Not Finding Objects from Search

First, I am new to LDAP and coding using LDAP. I have a simple issue that I am trying to debug within LDAP. I have spent the last 24 hrs looking at my code and searching for examples and configurations. I have a web app running on JBoss. I have created an external Context bean so I can lookup the connection in the JNDI Tree for my LDAP Server. I am getting a connection with no problem. When I search my LDAP Server for a UID, I am getting a NameNotFoundException. The exception message from LDAP says: LDAP: error code 32 - No Such Object. This makes me look at my search criteria.

Here is what I have:

I am using the LDAP Browser to connect to the LDAP Server. I am using the search tool within the LDAP Browser to verify my search criteria.

SearchControls ctls = new SearchControls();
ctls. setReturningObjFlag (true);
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
String filter = "(&(objectClass=*))";

InitialContext initCtx = new InitialContext();
LdapContext ldapCtx = (LdapContext) initCtx.lookup("ldapDataSource");

NamingEnumeration answer3 = ldapCtx.search("ou=People, ou=externalusers,    
                                            ou=EpicentricJNDIContext, 
                                            o=company.com", filter, ctls);

I have also changed the object class to person just to be sure. I am still getting not results.

I feel my code is right. I am now wondering if the user has the correct privileges to accomplish the search. Also, how do I know the LDAP structure is setup correctly so an application can search LDAP? It is my belief we are using Netscape Directory Server

Am I missing anything here? It seems the problem is right in front of me and I am not seeing it. Any suggestions or comments would be greatly appreciated.

Thanks

I have solved my problem. The issue was how I was binding to the LDAP server and how I was creating the DN.

SearchControls ctls = new SearchControls(); ctls. setReturningObjFlag (true);     
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); String filter = "(&    (objectClass=inetOrgPerson))";  
InitialContext initCtx = new InitialContext(); 
LdapContext ldapCtx = (LdapContext) 
initCtx.look开发者_开发问答up("ldapDataSource");  
NamingEnumeration answer3 = ldapCtx.search("ou=People, ou=externalusers,ou=EpicentricJNDIContext",filter,ctls); 


You don't need & in the filter unless you have multiple conditions to be &-ed together.

It's not your search criteria. The name that isn't being found is the first argument to search(), that being the only name. Check it.

You realize this search will return the entire subtree under the name once you fix it?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜