In this post under Java LDAP, I will show with example how to retrieve specific attributes when doing basic search. For our example we will use the below ldap hierarchy. Now lets see the main code which actually does the search. Main class 1 package package11; 2 3 import javax.naming.Context; 4 import javax.naming.NamingEnumeration; 5 import…… Continue reading Retrieving selected attribute when doing basic search
Tag: LDAP
Basic Search in LDAP
In this post under Java LDAP, I will show with example how to perform a basic search for entries in LDAP. I have below ldap tree. In this ldap tree under development department with dn “ou=dev”, I have three developers “user1”, “user2”, and “user3”. “user1” has “description” attribute with value “Softwareengineer 2” whereas “user2” and…… Continue reading Basic Search in LDAP
Renaming an ldap entry
In this post under Java LDAP, I will show with example how to rename an ldap entry. To rename an ldap entry, Java LDAP api provides “rename” method which takes two arguments1) the current name/fully qualified dn2) the new name/fully qualified dn Below is the complete main code for your reference Main class 1 package…… Continue reading Renaming an ldap entry
Removing an attribute of an ldap entry
In this post under Java LDAP, I will show with example two approaches to remove a existing attribute from an existing ldap entry. For our example I will remove an attribute by name “telephoneNumber” from an ldap entry identified by dn. Below is the complete main class for your reference Main class 1 package package7;…… Continue reading Removing an attribute of an ldap entry
Adding a new attribute for an ldap entry
In this post under Java LDAP, I will show with example how to add a new attribute to an existing ldap entry. For our example I will add a “telephoneNumber” attribute to an ldap entry identified by dn. I will show two approaches through which we can add a new attribute to an existing ldap…… Continue reading Adding a new attribute for an ldap entry
Modifying an existing attribute of a ldap entry
In this post under Java LDAP, I will show with example how to modify an existing attribute of an ldap entry. For our example I will modify the “description” attribute of an ldap entry identified by dn. I will show two approaches through which we can modify the attribute of an ldap entry. Below is…… Continue reading Modifying an existing attribute of a ldap entry
Deleting an LDAP entry
In this post under Java LDAP, I will explain how to delete an LDAP entry. The below figure shows the LDAP DIT (Directory Information Tree) I will show two approaches to delete an ldap entry or sub context. In the first approach we will delete the ldap entry with dn “cn=user3,ou=dev,dc=example,dc=org”. In the second approach…… Continue reading Deleting an LDAP entry
Creating a new entry in ldap
In this post under Java LDAP, I will show how to create a sub context with an example In LDAP, sub context means a new LDAP entry under another existing LDAP entry or context. Below is the screenshot of LDAP DIT (Directory Information Tree) I will show two approaches that can be used to create…… Continue reading Creating a new entry in ldap
Retrieving attribute of an ldap entry
In this post under Java LDAP, I will show with example how to retrieve an attribute of an existing ldap entry. For our example we will take the below ldap entry. Please note in the above screenshot, all the attributes have only one value except attribute “telephoneNumber” which has 2 values. Below is the complete…… Continue reading Retrieving attribute of an ldap entry
InitialDirContext lookup method
In this post under Java LDAP, I will show how to lookup for an entry in LDAP directory tree using ldap distinguished name. Below is the complete main class for your reference Main class 1 package package2; 2 3 import java.util.Hashtable; 4 5 import javax.naming.Context; 6 import javax.naming.NamingException; 7 import javax.naming.directory.DirContext; 8 import javax.naming.directory.InitialDirContext; 9…… Continue reading InitialDirContext lookup method