aspose file tools*
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
Author

Active Directory & JNDI

J Yau
Greenhorn

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.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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Active Directory & JNDI