Changing Directory Server Entries


ou change entries in your directory using LDAP clients. Most LDAP clients provide an interface that allows you to change, delete, or add entries to your directory. Note, however, that you cannot modify your directory unless the appropriate access control has been set in your directory. For information on setting access control in your directory, see
Chapter 5, "Managing Access Control."

The Netscape Directory Server comes with the following LDAP clients that allow you to modify your directory:

For information on how to use the Users and Groups area of the administration server, see the online help that is available through your administration server. For information on how to use the directory server gateway, see the online help that is available through the gateway.

The remainder of this chapter discusses the usage of the ldapmodify and ldapdelete command-line utilities.

 

Using the Command-Line Utilities

The command-line client utilities allow you to manipulate the contents of your directory. They are just one of the many options you have for managing your directory. The command-line utilities are especially useful for writing scripts to perform bulk management of your directory, or for testing your directory server to ensure that it is working correctly (especially if you have changed your access control information) or written a custom client.

 

Using Special Characters

When using the directory server command-line client tools, you may need to specify values that contain characters that have special meaning to the command-line interpreter (such as space [ ], asterisk [*], backslash [\], and so forth). When this situation occurs, enclose the value in quotation marks (""). For example:


-D "cn=Barbara Jensen, ou=Product Development, o=airius.com"


-D "cn=Patricia Fuentes, ou=people, o=Airius Bolivia\, S.A."

 

Providing Input from the Command Line

ldapmodify and ldapdelete allow you to provide input both from an input file (using the -f parameter), as well as from the command line. If you want to provide input from the command line, do not specify the -f parameter when you call these commands.

The tool collects statements that you enter to the shell in exactly the same way as if they were reading from a file. When you are done providing input to the utility, enter the character that your shell recognizes as the end of file (EOF) marker. This causes the utility to begin operations based on the input you have supplied.

Typically, the EOF escape sequence is usually one of the following, depending upon the type of machine that you are using:

For example, suppose you wanted to specify some LDIF update statements to ldapmodify. Then you would do the following:


prompt> ldapmodify -D <bindn> -w <password> -h <hostname> 
> dn: cn=Barry Nixon, ou=people, o=airius.com
> changetype: modify
> delete: telephonenumber
> -
> add: manager
> manager: cn=Harry Cruise, ou=people, o=airius.com
> ^D
prompt>
 

Deleting Entries Using ldapdelete

You use the ldapdelete command-line utility to delete entries from an existing directory server database. This utility opens a connection to the specified server using the specified distinguished name and password, and deletes the entry or entries.

For information on where you can find the command-line utilities in your directory server installation, see "Finding the Command-Line Utilities".

 

A Note on Deleting Entries

You can only delete entries at the end of a branch. You cannot delete entries that are branch points in the directory tree. For example, of the following three entries:


	ou=People, o=airius.com
cn=Paula Simon, ou=People, o=airius.com
cn=Jerry O'Connor, ou=People, o=airius.com
you can delete only the last two entries. The entry that identifies the People subtree can be deleted only if no other entries exist below it.

 

Commonly Used ldapdelete Parameters

To delete an entry or entries from an existing database, use the ldapdelete command-line utility with the following parameters:

 

SSL Parameters

You can use the following parameters to specify that ldapdelete is to use LDAPS when communicating with your directory server. These parameters are valid only when LDAPS has been turned on and configured for your directory server. For more information on LDAPS, see "Managing SSL".

Make sure that you specify your directory server's encrypted port when you use these parameters:

 

Additional ldapdelete Parameters

The following parameters offer additional functionality:

 

ldapdelete Examples

Suppose:

Then to delete the entries for users Robert Jenkins and Lisa Jangles, enter the following command:


ldapdelete -D "cn=Directory Manager, o=airius.com" -w King~Pin -h cyclops -p 845 "cn=Robert Jenkins, ou=People, o=airius.com" "cn=Lisa Jangles, ou=People, o=airius.com"

To delete user Patricia Fuentes from the Airius Bolivia, S.A. tree, you would enter the following command. Note that because the DN of the entry you are deleting contains a comma, you must escape the comma with a backslash (\).


ldapdelete -D "cn=Directory Manager, o=airius.com" -w King~Pin -h cyclops -p 845 "cn=Patricia Fuentes, ou=People, o=Airius Bolivia\, S.A."

 

Adding Entries

You can create one or more entries by using the ldapmodify command along with the appropriate LDIF update statements. For details, refer to "Modifying Entries Using ldapmodify".

You can also use an LDIF file to add multiple entries by using the Database Management | Add Entries form.

Finally, you can also import an entire database from LDIF. For details, refer to "Importing LDIF Using the Server Manager". For details on LDIF, see Chapter 2, "LDAP Data Interchange Format."

 

A Note on Adding Entries

When you add an entry, make sure that an entry representing a branch point is created before new entries are created under that branch. For example, if you want to place an entry in a Person and a Group subtree, then create the branch point for those subtrees before creating entries within the subtrees. For example:


	dn: o=airius.com
dn: ou=People, o=airius.com
...
<People subtree entries.>
...
dn: ou=Group, o=airius.com
...
<Group subtree entries.>
...
 

Adding Entries Using the Server Manager

You can add entries from the server manager. To do so, you define the entries using an LDIF file (LDIF is described in Chapter 2, "LDAP Data Interchange Format."). Do the following:

  1. Make sure the directory server is running.

  2. From the server manager, go to Database Management | Add Entries.

  3. In the Full path to LDIF file field, enter the full pathname to the LDIF file that contains the entries you want to add to your directory. Note that unlike other forms in the server manager that allow you to specify LDIF files, you do not have to place this file in the <NSHOME>/slapd-<serverID>/ldif directory.

  4. Fill in the Bind to Server as and Password fields, if necessary. See "Binding to the Directory" for more information.

  5. Click OK. The entries are added immediately to your directory.

 

Modifying Entries Using ldapmodify

You use the ldapmodify command-line utility to modify entries in an existing directory server database. This utility opens a connection to the specified server using the specified distinguished name and password, and modifies the entries based on LDIF update statements contained in a specified file.

For information on where you can find the command-line utilities in your directory server installation, see "Finding the Command-Line Utilities".

 

Commonly Used ldapmodify Parameters

To modify an entry or entries in an existing directory, use the ldapmodify command-line utility with the following parameters:

 

SSL Parameters

You can use the following command-line parameters to specify that ldapmodify is to use LDAPS when communicating with your directory server. These parameters are valid only when LDAPS has been turned on and configured for your directory server. For more information on LDAPS, see "Managing SSL".

Make sure that you specify your directory server's encrypted port when you use these parameters:

 

Additional ldapmodify Parameters

The following parameters offer additional functionality:


	jpegPhoto: /tmp/photo.jpeg


	jpegPhoto: c:/tmp/photo.jpeg

 

ldapmodify Examples

Suppose:

Then to modify the entries, first specify the appropriate LDIF update statements in the modify_statements file, and then enter the following command:


ldapmodify -D "cn=Directory Manager, o=airius.com" -w King~Pin -h cyclops -p 845 -f modify_statements

 

LDIF Update Statements

You use LDIF update statements to define how ldapmodify should change your directory. In general, LDIF update statements are a series of statements that:

The general format of LDIF update statements is as follows:


	dn: <distinguished name>
<changetype identifier>
<change operation identifier>
<list of attributes>
... - <change operation identifier>
<list of attributes>
...
- ...

	dn: cn=Lisa Jangles, ou=People, o=airius.com 
changetype: modify
add: telephonenumber
telephonenumber: (408) 555-2468
-
add: manager
manager: cn=Harry Cruise, ou=People, o=airius.com
In addition, the line continuation operator is a single space. Therefore, the following two statements are identical:


	dn: cn=Lisa Jangles, ou=People, o=airius.com 


	dn: cn=Lisa Jangles,
ou=People,
o=airius.com
The following sections describe the changetypes in detail.

 

Adding an Entry

You use changetype: add to add an entry to your directory. When you add an entry, make sure to create an entry representing a branch point before you try to create new entries under that branch. That is, if you want to place an entry in a People and an Groups subtree, then create the branch point for those subtrees before creating entries within the subtrees. For more information, see "A Note on Adding Entries".

The following LDIF update statements can be used to create the People and the Groups subtrees, and then create entries within those trees:


dn: o=airius.com
changetype: add
objectclass: organization
o: Airius Corporation
dn: ou=People, o=airius.com
changetype: add
objectclass: organizationalUnit
ou: People
ou: Marketing
dn: cn=Pete Minsky, ou=People, o=airius.com
changetype: add
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Pete Minsky
givenName: Pete
sn: Minsky
ou: People
ou: Marketing
uid: pminsky
dn: cn=Sue Jacobs, ou=People, o=airius.com
changetype: add
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Sue Jacobs
givenName: Sue
sn: Jacobs
ou: People
ou: Marketing
uid: sjacobs
dn: ou=Groups, o=airius.com
changetype: add
objectclass: organizationalUnit
ou: Groups
dn: cn=Administrators, ou=Groups, o=airius.com
changetype: add
objectclass: groupOfNames
member: cn=Sue Jacobs, ou=People, o=airius.com
member: cn=Pete Minsky, ou=People, o=airius.com
cn: Administrators

dn: ou=Airius Bolivia\, S.A., o=airius.com
changetype: add
objectclass: organizationalUnit
ou: Airius Bolivia\, S.A.

dn: cn=Carla Flores, ou=Airius Bolivia\, S.A., o=airius.com
changetype: add
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Carla Flores
givenName: Carla
sn: Flores
ou: Airius Bolivia\, S.A.
uid: cflores
 

Using the ldapmodify -a Parameter

If you are simply adding entries to your directory, you can avoid the changetype: add statement by specifying the -a parameter on the call to ldapmodify. In this case, simply provide LDIF (as opposed to LDIF update statements) to ldapmodify. For example:


> ldapmodify -a -h <hostname> -p <port> -D <bind dn> -w <password>
dn: o=airius.com
objectclass: organization
o: Airius Corporation
dn: ou=People, o=airius.com
objectclass: organizationalUnit
ou: People
dn: cn=Pete Minsky, ou=People, o=airius.com
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Pete Minsky
givenName: Pete
sn: Minsky
ou: People
ou: Marketing
...

^z

 

Deleting an Entry

You use changetype:delete to delete an entry from your directory. You can only delete entries at the end of a branch. Therefore, when you delete an entry, make sure that no other entries exist under that entry in the directory tree. That is, you cannot delete an organizational unit entry unless you have first deleted all the entries that belong to the organizational unit.

For example, of the following three entries:


	ou=People, o=airius.com
cn=Paula Simon, ou=People, o=airius.com
cn=Jerry O'Connor, ou=People, o=airius.com
you can delete only the last two entries. The entry that identifies the People subtree can be deleted only if no other entries exist below it.

The following LDIF update statements can be used to delete person entries:


dn: cn=Pete Minsky, ou=People, o=airius.com
changetype: delete
dn: cn=Sue Jacobs, ou=People, o=airius.com
changetype: delete
 

Renaming an Entry

You use changetype:modrdn to change an entry's relative distinguished name (RDN). An entry's RDN is the leftmost element in the distinguished name. Therefore, the RDN for:


	cn=Barry Nixon, ou=People, o=airius.com

is:


	cn=Barry Nixon

And the RDN for:


	ou=People, o=airius.com

is:


	ou=People

Therefore, this rename operation allows you to change the left-most value in an entry's distinguished name. For example, the entry:


	cn=Sue Jacobs, ou=People, o=airius.com

can be modified to be:


	cn=Susan Jacobs, ou=People, o=airius.com

but it cannot be modified to be:


	cn=Sue Jacobs, ou=old employees, o=airius.com

The following example can be used to rename Sue Jacobs to Susan Jacobs:


	dn: cn=Sue Jacobs, ou=Marketing, o=airius.com
changetype: modrdn
newrdn: cn=Susan Jacobs
deleteoldrdn: 0
Because deleteoldrdn is 0, this example retains the existing RDN in the new entry. The resulting entry would therefore have a common name (cn) attribute set to both Sue Jacobs and Susan Jacobs in addition to all the other attributes included in the original entry.

 

A Note on Renaming Entries

You cannot rename an entry with the modrdn changetype such that the entry moves to a completely different subtree. To move an entry to a completely different branch you must create a new entry in the alternative subtree using the old entry's attributes, and then delete the old entry.

Also, for the same reasons that you cannot delete an entry if it is a branch point, you cannot rename an entry if it has any children. Doing so would orphan the children in the tree, which is not allowed by the LDAP protocol. For example, of the following three entries:


	ou=People, o=airius.com
cn=Paula Simon, ou=People, o=airius.com
cn=Jerry O'Connor, ou=People, o=airius.com
you can only rename the last two entries. The entry that identifies the People subtree can only be renamed if no other entries exist below it.

 

Modifying an Entry

Use changetype:modify to add, replace, or remove attributes and/or attribute values to the entry. When you specify changetype:modify, you must also provide a change operation to indicate how the entry is to be modified. Change operations can be:

This section contains the following topics:

 

Deleting an Attribute

You use changetype:modify with the delete operation to delete an attribute from an entry. If the entry has more than one instance of the attribute, you must indicate which of the attributes you want to delete.

For example, the following LDIF update statement deletes all instances of the telephonenumber attribute from the entry, regardless of how many times it appears in the entry:


	dn: cn=Barney Fife, ou=People, o=airius.com
changetype: modify
delete: telephonenumber
If you want to delete just a specific instance of the telephonenumber attribute, then you simply delete that specific attribute value. The following section describes how to do this.

 

Deleting an Attribute Value

You use changetype:modify with the delete operation to delete an attribute value from an entry. You must then indicate which of the actual attributes you want to delete.

For example, consider the following entry:


	cn=Barney Fife, ou=People, o=airius.com
objectClass: inetOrgPerson
cn: Barney Fife
sn: Fife
telephonenumber: 555-1212
telephonenumber: 555-5678
To delete the 555-1212 telephone number from this entry, use the following LDIF update statement:


	dn: cn=Barney Fife, ou=People, o=airius.com
changetype: modify
delete: telephonenumber
telephonenumber: 555-1212
Barney's entry then becomes:


	cn=Barney Fife, ou=People, o=airius.com
objectClass: inetOrgPerson
cn: Barney Fife
sn: Fife
telephonenumber: 555-5678
 

Adding Attributes

You use changetype:modify with the add operation to add an attribute and an attribute value to an entry.

For example, the following LDIF update statement adds a telephone number to the entry:


	dn: cn=Barney Fife, ou=People, o=airius.com
changetype: modify
add: telephonenumber
telephonenumber: 555-1212
The following example adds two telephone numbers to the entry:


	dn: cn=Barney Fife, ou=People, o=airius.com
changetype: modify
add: telephonenumber
telephonenumber: 555-1212
telephonenumber: 555-6789
The following example adds two telephonenumber attributes and a manager attribute to the entry:


	dn: cn=Barney Fife, ou=People, o=airius.com
changetype: modify
add: telephonenumber
telephonenumber: 555-1212
telephonenumber: 555-6789
-
add: manager
manager: cn=Sally Nixon, ou=People, o=airius.com
The following example adds a jpeg photograph to the directory. The jpeg photo can be displayed by the gateway. Note that in order to add this attribute to the directory, you must use the ldapmodify -b parameter (which indicates that ldapmodify should read the referenced file for binary values if the attribute value begins with a slash (/)):

dn: cn=Barney Fife, ou=People, o=airius.com
changetype: modify
add: jpegphoto
jpegphoto: /path/to/photo

 

Changing an Attribute Value

You use changetype:modify with the replace operation to change an attribute value when there is only a single instance of that attribute in the entry.

For example, the following LDIF update statement changes Barney's manager from Sally Nixon to Wally Hensford:


	dn: cn=Barney Fife, ou=People, o=airius.com
changetype: modify
replace: manager
manager: cn=Wally Hensford, ou=People, o=airius.com
If the entry has multiple instances of the attribute, then to change one of the attribute values, you must delete the attribute value that you want to change, and then add the replacement value. For example, consider the following entry:


	cn=Barney Fife, ou=People, o=airius.com
objectClass: inetOrgPerson
cn: Barney Fife
sn: Fife
telephonenumber: 555-1212
telephonenumber: 555-5678
To change 555-1212 to 555-4321, use the following LDIF update statement:


	dn: cn=Barney Fife, ou=People, o=airius.com
changetype: modify
delete: telephonenumber
telephonenumber: 555-1212
-
add: telephonenumber
telephonenumber: 555-4321
Barney's entry now is now as follows:


	cn=Barney Fife, ou=People, o=airius.com
objectClass: inetOrgPerson
cn: Barney Fife
sn: Fife
telephonenumber: 555-5678
telephonenumber: 555-4321
 

Modifying an Entry in an Internationalized Directory

If the attribute values in your directory are associated with one or more languages other than English, the attribute values are associated with language tags. When using the ldapmodify command-line utility to modify an attribute that has an associated language tag, you must match the value and language tag exactly or the modify operation will fail.

For example, if you want to modify an attribute value that has a language tag of lang-fr, you must include the lang-fr in the modify operation as follows:


dn: bjensen, o=airius.com
changetype: modify
replace: homePostalAddress;lang-fr
homePostalAddress;lang-fr: 34 rue Seine