This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Active Directory & JNDI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "Active Directory & JNDI" Watch "Active Directory & JNDI" New topic

Active Directory & JNDI

J Yau

Joined: Jul 29, 2003
Posts: 3
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.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");
} 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
Have you checked out Aspose?
subject: Active Directory & JNDI
jQuery in Action, 3rd edition