Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to add a user in the Active Directory via JNDI/LDAP?

 
Fansy Zjy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI all,
I am puzzled how to add a user in AD,please show your hands?
Server : Win2k Advanced Server,Active Directory,Exchange Server 2000
Client : jdk1.4
I access AD via JNDI/LDAP to add an entry,and the codes as below
public void addUser(){
/* Specify the DN we're adding */
String dn = "CN=test1,CN=Users,DC=acdemo,DC=com";
Attribute cn = new BasicAttribute("cn", "test1");
Attribute objClasses = new BasicAttribute("objectClass");
objClasses.add("top");
objClasses.add("person");
objClasses.add("organizationalPerson");
objClasses.add("user");
Attribute instanceType = new BasicAttribute("instanceType", "4");
Attribute objectCategory = new BasicAttribute("objectCategory", "CN=Person,CN=Schema,CN=Configuration,DC=acdemo,DC=com");
......
Attributes orig = new BasicAttributes(true);
orig.put(objClasses);
orig.put(cn);
orig.put(instanceType);
orig.put(objectCategory);
......
Hashtable env = new Hashtable(5, 0.75f);
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://172.16.251.212");
/* specify authentication information */
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "CN=Administrator,CN=Users,DC=acdemo,DC=com");
env.put(Context.SECURITY_CREDENTIALS, "pass");//password
DirContext ctx = null;
try {
ctx = new InitialDirContext(env);
/* Add the entry */
ctx.createSubcontext(dn, orig);
}
catch (NamingException e) {
e.printStackTrace();
}
}
when I run,it throws the exception as below:
javax.naming.OperationNotSupportedException: [LDAP: error code 53 - 0000209A: SvcErr: DSID-031A0929, problem 5003 (WILL_NOT_PERFORM), data 0
...
Anybody can help me?
I got points from SUN's forum that I should make a SSL connection between C/S,but may you show me a step-by-step guides?
Thanks in advance
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Security forum.
Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic