java2db

Add new entry to LDAP using java JNDI



Java Naming and Directory Interface (JNDI)  provides service for the LDAP communication. Using this service , easily we can add new entry to LDAP.

Basic requirements for authentication :

Add new entry to LDAP IP address and port of the LDAP server.

Add new entry to LDAP LDAP Admin DN and password.

 

Example LDAP directory structure :

LDAP-Directory-Structure

 

 

Process to add new entry to LDAP :

Add new entry to LDAP First connect to the LDAP server  as an admin (having access to add) .

Add new entry to LDAP Create user DN  , to add new entry to LDAP .

……..Example: If you want to add the new entry uid=145  in  ou=physics directory,then the  DN will be  ……..uid=145,ou=physics,dc=sciencedep,dc=college .

Add new entry to LDAP  Add required attribute values .

 

Java example to add new entry to LDAP :

Execution Result:

From the above example code :

Add new entry to LDAP  ldaps://10.160.2.11:1500  is the LDAP server URL   .
Add new entry to LDAP  cn=LDAP Administrator,dc=college,dc=org,dc=in  is the Administrator DN .
Add new entry to LDAP  Connection type is “simple” ,that means  it will take the plain text as password for authentication.

Add new entry to LDAP  line 56 to 79 , we are passing values to the required attributes .
Add new entry to LDAP  dirContext.createSubcontext(entryDN, entry)   method will create the new entry in LDAP .

Note :If  the  same entry (DN) already exist in the specified location ,it throws an Entry already exist Exception




Related Posts :
How to Connect to Oracle from Liferay portlet ( Java Liferay and Oracle integration )
How to Connect Liferay 7 to PostgreSQL ( Java Liferay portlet and PostgreSQL integration )
How to call C# .Net WCF web service in java SOAP client ( Visual Studio 2013 )
How to call PHP RESTful web service in java client
How to call java SOAP web service in php ( php web service client )
Solution to SSLHandshakeException (skip the certificate for Java and LDAP bind)
Java RESTful web service example in maven using JAX-RS
RESTful web service example in java using JAX-RS
   [will not be published]



^ <