Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Active Directory & JNDI  RSS feed

J Yau
Posts: 3
  • Mark post as helpful
  • send pies
  • 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.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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!