ldapadd, ldapmodify, ldapsearch

ldapadd, ldapmodify are command line or shell accessible ways to add or modify entries into a LDAP Directory Information Tree or DIT. Similarly ldapsearch can be used to search for existing entries in a LDAP Directory.

(1) ldapadd 
ldapadd can be used to add a new entry to a LDAP Directory. Here is an example of how to use the ldapadd command to add a new user via the command line. One can add a new user via the GUI or user interface for the LDAP Directory. 
For this example we will add a new user, say "user3" to LDAP Directory. See the screenshot below with the complete command and syntax. The syntax of the command is   
ldapadd -h localhost -p 3060 -D cn=orcladmin -w xxxx << EOF  
(and then press Enter, to continue adding the various entries required.)
Below is a complete example that should enter a new user entry into the LDAP Directory. Here cn=orcladmin is the administrator account which is being used to interact with the Oracle Internet Directory (OID) with -w option or flag for the password of this orcladmin administrator account. 
The DN or Distinguished Name of the user, user3 is based on the LDAP Tree. e.g the DN in below example is  cn=user3,cn=Users,dc=oracle,dc=com. (oracle and com is an example, it could be different depending upon your Directory).
 If the entry was accepted into the Directory, you should see the message - adding new entry (as shown in above screenshot)
Note: In the above example, End-of-File (EOF) is being used to input data into the ldapadd command via command line. Other technique to input data to ldapadd command can be via a ldif file (i.e. instead of the EOF as shown above, or use the -f flag/option to specify the filename. The file would contain the same above information in the ldif format.) 
LDIF - LDAP Data Interchange Format is a well known and documented as a standard in RFC 2849, read here.

(2) ldapmodify
ldapmodify is a command used to modify an existing attribute in the Directory. Below is ldapmodify example from Oracle Internet Directory (OID)
In above example, the entry for "sn" attribute has been modified, to new value of "NewHere".

(3) ldapsearch
The ldapsearch command-line tool enables you to search for and retrieve specific entries in the directory.

http://oamoim.blogspot.com/2016/12/ldapsearch-command-line.html


ldapadd, ldapmodify, ldapsearch are utilities to interact with LDAP directories, e.g. Oracle Internet Directory (OID), Oracle Unified Directory (OUD), OpenLDAP, etc.
Refer some interesting articles on LDAP (these are specific to OID but should apply to any LDAP compliant directory)
Get listing of locked user accounts (can be applied to listing of accounts based on your own filter or condition)

Note: Usage of ldapadd and ldapmodify via text file
Here is another method of using ldapadd command that can be used with a text file to add a user. The text file contains user and user information. See below example of using this method of using a text file (here user3.ldif) for adding a user instead of the above ldap command provided above where the entry attributes were added manually.
The syntax of the ldapadd command with file provided as a parameter would be   

ldapadd -h  localhost -p 3060 -D cn=orcladmin -w password -f user3.ldif

Below are contents of user3.ldif
dn: cn=user3,cn=Users,dc=oracle,dc=com
changetype: add
uid: user3
mail: user
givenName: user3
cn: testuser
sn: testuser
userpassword: abc
description:  user3 description
objectClass: top
objectClass: person
objectClass: organizationalperson
objectClass: inetorgperson
objectClass: orcluser
objectClass: orcluserV2

Similarly the ldapmodify command can also be provided with a text file (in below example text file is user3mod.ldif) as input. The syntax of the ldapadd command with file provided as a parameter would be    

ldapadd -h  localhost -p 3060 -D cn=orcladmin -w password -f user3mod.ldif

Below are contents of user3mod.ldif
dn: cn=users,cn=Users,dc=oracle,dc=com
changetype: modify
replace: sn
sn: NewHere




Comments

Popular posts from this blog

VMware fix for Invalid manifest and ova file import failed errors

SOAPUI - import certificate

Centrally Managed Users (CMU) - New Feature in Oracle Database 18c