• 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:

Accessing Microsoft AD LDAP through JNDI

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Our first order of business must be this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic