This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Accessing Microsoft AD LDAP through JNDI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Accessing Microsoft AD LDAP through JNDI" Watch "Accessing Microsoft AD LDAP through JNDI" New topic
Author

Accessing Microsoft AD LDAP through JNDI

Makrand Pare
Greenhorn

Joined: Dec 07, 2005
Posts: 10
Hi,

I want to lookup some names in Microsoft AD LDAP server. I'm using JNDI APIs to connect and lookup names from that LDAP server.
I'm successfully able to make a connection to the LDAP server however while looking up the name it gives me the following exception:

Lookup failed: javax.naming.NamingException: [LDAP: error code 1 - 000020D6: Svc
Err: DSID-031006CC, problem 5012 (DIR_ERROR), data 0 ]; remaining name 'cn=parema'
javax.naming.NamingException: [LDAP: error code 1 - 000020D6: SvcErr: DSID-03100
6CC, problem 5012 (DIR_ERROR), data 0
]; remaining name 'cn=parema'
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3025)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2931)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2737)
at com.sun.jndi.ldap.LdapCtx.c_lookup(LdapCtx.java:993)
at com.sun.jndi.toolkit.ctx.ComponentContext.p_lookup(ComponentContext.java:526)
at com.sun.jndi.toolkit.ctx.PartialCompositeContext.lookup(PartialCompositeContext.java:159)
at com.sun.jndi.toolkit.ctx.PartialCompositeContext.lookup(PartialCompositeContext.java:148)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at Lookup.main(Lookup.java:61)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I'm using the following code to connect to the LDAP:

Hashtable<String, Object> env = new Hashtable<String, Object>(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "LDAP://CORP.WEYER.PRI");
env.put(Context.SECURITY_PRINCIPAL, "parema@CORP");
env.put(Context.SECURITY_CREDENTIALS, "mycorppassword!");

Context ctx = new InitialContext(env);
// Perform lookup and cast to target type
LdapContext b = (LdapContext) ctx.lookup("cn=parema");

I'm sure that I'm able to connect to the LDAP server as I'm using my corp username and password to connect to it. In case I use any other username and password, it gives me an javax.naming.AuthenticationException.

Please let me know if this is the right way to lookup values from an LDAP server?

Thanks,
Makrand
 
wood burning stoves
 
subject: Accessing Microsoft AD LDAP through JNDI
 
Similar Threads
LDAP Search
Active Directory Authentication
Active Directory & JNDI
Change Ldap Password
AD LDAP Authentication & Data Fetch Error.