| LDAP commands and scripts |
|
|
|
| Monday, 19 February 2007 16:00 | |||||||||||
This is boring stuff, but needed to build and maintain your ldap directory.
Renaming an LDAP entryThe modrdn LDAP operation allows an authorized user to rename an LDAP entry’s RDN (that is, modifying the RDN of that entry).Optionally, the modrdn operation can keep the old attributes that form the pristine RDN. This can be accomplished by specifiying deleteOldRDN:0 at the end of the modrdn data. If deleteOldRND:1 is specified at the end of the modrdn operation, or it is not specified at all, the modrdn operation will keep the attributes (and its values) that formed the pristine RDN. For example, let’s add a sample entry: $ ldapmodify …
The attributes for the newly added entry are: $ ldapsearch -x
Now, using the ldapmodify command, let’s invoke the modrdn operation onto the sample entry: $ ldapmodify …
Since deleteOldRND:1 has been specified, the old cn attribiute (commonName), which was part of the RDN, is removed and then replaced by the new cn attribute and it’s new value. $ ldapsearch -x
Should have we specified deleteOldRND:0, then the entry would have looked as follows: $ ldapsearch -x
Scripts to make your life easierThe following are examples of the simple scripts for adding/deleting/modifying LDAP users. Keep in mind, that you first need to create local user on the server and than with the script, you export it to the LDAP. It's the exact same thing as we were doing earlier, only this can be automatically done with the following script. > Create ldapuser_add script and copy/paste the following lines in
Watch for the line brakes, because you will end up with errors if the line breake on some different point. Now, make the script executable and place it somewhere in your PATH. > Script ldapuser_delete for deleting LDAP users from database
[root@ldap ~]# chmod 700 ldapuser_delete > Script ldapuser_modify for modifying LDAP users
[root@ldap ~]# chmod 700 ldapuser_modify
|