• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Active Directory & JNDI

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I'm new to JDNI and Active Directory, I'm using the example from JNDI tutorial and modify it to access the existing active directory server from my company. The code is as follow:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import javax.naming.Context;
import javax.naming.directory.InitialDirContext;
import javax.naming.directory.DirContext;
import javax.naming.directory.Attributes;
import javax.naming.NamingException;
import java.util.Hashtable;
class Getattr {
public static void main(String[] args) {
// Identify service provider to use
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://<IP of ADS>:<PORT of ADS>/o=<root of the active directory tree>");
try {
DirContext ctx = new InitialDirContext(env);
Attributes attrs = ctx.getAttributes("cn=jennifer.yau");
ctx.close();
} catch (NamingException e) {
System.err.println("Problem getting attribute: " + e);
}
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
But I always have the followig error msg:
Problem getting attribute: javax.naming.NamingException: [LDAP: error code 1 - 000020D6: SvcErr: DSID-03100690, problem 5012 (DIR_ERROR), data 0 ]; remaining name 'cn=jennifer.yau'
1) I'm not sure whether I connect to ADS correctly?
2) in o=<root of the active directory tree>, is it correct? where should I find the information from active directory to put into this sentence?
3) in cn=jennifer.yau, is active directory contains the attribute "cn"? Where can I know the attribute name can be used?
4) What's the coz of the error here?
Some many unknow, but hoping that someone can help me
Jennifer
reply
    Bookmark Topic Watch Topic
  • New Topic