Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within EJB and other Jakarta /Java EE Technologies
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Ron McLeod
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
EJB and other Jakarta /Java EE Technologies
LDAP Search
Micale Raj
Ranch Hand
Posts: 30
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi all
I'm new to LDAP. I'm trying to search in LDAP to get users email address. But I get NamingException
My Code
try { Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://xxx.xxx.com:1234/dc=abc, dc=com"); env.put("com.sun.jndi.ldap.connect.timeout", "5000"); DirContext ctx = new InitialDirContext(env); Attributes matchAttrs = new BasicAttributes(true); // ignore attribute name case matchAttrs.put(new BasicAttribute("mail")); NamingEnumeration answer = ctx.search("ou=People", matchAttrs); while (answer.hasMore()) { SearchResult sr = (SearchResult) answer.next(); System.out.println(">>>" + sr.getName()); } } catch (NamingException ex) { Logger.getLogger(JavaApplicationEmailTest.class.getName()).log(Level.SEVERE, null, ex); }
I get following error
javax.naming.InvalidNameException: ou=People: [LDAP: error code 34 - invalid DN]; remaining name 'ou=People' at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2979) at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2794) at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1826) at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1749) at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1741) at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:344) at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:299) at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:281) at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:265) at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:210) at javaapplicationemailtest.JavaApplicationEmailTest.getEmailAddress(JavaApplicationEmailTest.java:55) at javaapplicationemailtest.JavaApplicationEmailTest.main(JavaApplicationEmailTest.java:27)
How can I fix this? Thank you!
Micale Raj
Ranch Hand
Posts: 30
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
HI all
I got the solution. I changed following line and it worked !
env.put(Context.PROVIDER_URL, "ldap://xxx.xxx.com:1234/");
Thanks !
This will take every ounce of my mental strength! All for a tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
LDAP and NamingEnumeration
Windows Authentication Using Tomcat 5.0
[LDAP: error code 32 - No Such Object]; remaining name ''
LDAP: error
LDAP: error code 53 - Function Not Implemented
More...