Click here to Skip to main content
15,890,982 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it possible to create an user account using LDAP in java programing?
Posted

1 solution

This[^] may lead you to your solution. Remember, Google is your friend.
 
Share this answer
 
Comments
Balaji_Reddy 6-Jan-12 9:56am    
its showing the following error . I just followed the same thing wat is mentioned URL


javax.naming.directory.NoSuchAttributeException:
fjdiewornncalwe 6-Jan-12 11:05am    
+5. Excellent link.
Balaji_Reddy 9-Jan-12 1:54am    
Thanks for your kind reply.

I was trying the same but still i'm getting the same exception. I have posted my code here and plz tel me where is the problem.



Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://192.168.168.103:389");
env.put(Context.SECURITY_PRINCIPAL, "xxxxxx");
env.put(Context.SECURITY_CREDENTIALS, "yyyyy");
String entryDN = "uid=testuser, DC=example, DC=com";

DirContext dirContext = new InitialDirContext(env);

Attribute commonName = new BasicAttribute("cn", "Test User");
Attribute surName = new BasicAttribute("su", "myuserid");
Attribute userID = new BasicAttribute("uid", "testuser");

//Object class addition
Attribute objectClass = new BasicAttribute("objectClass");
objectClass.add("top");
objectClass.add("person");
objectClass.add("organizationalPerson");
objectClass.add("user");
objectClass.add("inetOrgPerson");

Attributes entry = new BasicAttributes(true);

entry.put(userID);
entry.put(commonName);
entry.put(surName);

entry.put(objectClass);
DirContext createSubcontext = dirContext.createSubcontext("cn=testuser,DC=example,DC=com", entry);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900