Recently I've done a number of articles covering the Lightweight Directory Access Protocol (LDAP) which range from installation, adding entries, to full-blown GUI management tools (See LDAP content on Ghacks for more information). If you're in the dark about LDAP is an application protocol that allows the querying and modifying of directory services data implemented on IP networks. Basically it's a complex, large, directory of information of various forms that can be used for many, varied implementations (company addressbooks, application authentication, etc).
Once LDAP is installed you have, at your fingertips, plenty of tools to add, edit, and delete data on that server. One of those tools is critical to keeping data current. That tool is ldapmodify. In this article I am going to show you how to use this tool to modify an entry in an LDAP server.
The ldapmodify command isn't exactly like all other commands. Instead of just running a single command and being done with it, you issue the command, do you work, and then escape out of the command. The actual modification of the data doesn't happen until you escape the command. The sequence goes like this:
Yes, it does seem like a fairly complex process...and yes it is a complex, but a very necessary process.
Let's take a look at the actual process. As an example I am going to modify the gecos entry of an already existing directory entry. The gecos entry is a general information field that can be used for just about anything). Let's have some fun and change the gecos entry for user scooper and indicate that Sheldon Cooper is a Theoretical Physicist at Caltech University. We'll assume the gecos entry only contains the information "Sheldon Cooper" and the LDAP server's is on 192.168.1.10 and the full dc is wallen.local. Here is the actual process for this task:
Issue the command:
ldapmodify -h localhost -x -W -D "cn=admin,dc=wallen,dc=local"
It will now seem like the command is stuck. It's actually just waiting for input. The input will look like this (hit Enter after each line):
gecos: Theoretical Physicist, Caltech University
Once you have completed entering this text, hit Enter, and then hit CTRL-d to escape the command and then you should see something like:
modifying entry "uid=scooper,ou=People,dc=wallen,dc=local"
Now if you issue the ldapsearch command you will see the changes made. The ldapsearch command would look something like:
ldapsearch -x -b "dc=wallen,dc=local" -s sub "objectclass=*"
You should see Sheldon's listing like this:
# scooper, People, wallen.local
cn: Sheldon Cooper
gecos: Theoretical Physicist Caltech University
You now have modified the entry. Of course you aren't limited to the gecos entry. You can actually modify any entry you want using the same technique.
Hopefully LDAP is getting easier and easier for you. You can now add and modify entries. We will keep digging and eventually you will have the LDAP basics mastered.
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.