Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

Fansy Zjy
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");
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);
Hashtable env = new Hashtable(5, 0.75f);
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://");
/* 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) {
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Security forum.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!