PreviousNext

Main Program Procedural Steps

The program consists of the following general steps:

1. Examine the command-line argument to determine the type of operation (read, add, or delete entry) that the user wants to perform.

2. Initialize a workspace.

3. Pull in the packages with the required XDS features.

4. Prompt the user for the name entry on which the operation will be performed.

5. Convert the DCE-formatted user input string to an XDS object name.

6. Bind (without credentials) to the default server.

7. Perform the requested operation (read, add, or delete entry).

8. Perform error handling.

9. Unbind from the server.

10. Shut down the workspace, releasing resources back to the system.

Step 1 simply involves determining which of the three options (r (read), a (add), or d (delete)) the user has entered. Step 2 initializes a workspace, an operation required by XDS API for every application program. Step 3 is required because additional features not present in the directory service package need to be used by the application program. An additional package, the basic directory contents package, is defined in featureList as a static XDS object earlier in the program.

In Step 4, the user is prompted for the DCE-formatted name, which is the distinguished name of the person on whose telephone number the operation is to be performed. The name must be a fully or partially qualified name that begins with either the /... or /.: prefix. An example of a fully qualified, or global, name is /.../C=de/O=sni/OU=ap/CN=klaus. An example of a partially qualified, or cell, name is /.:/brad/sni/com. Additional information is requested in Step 5 if the user requests an add operation.

Step 5 converts the DCE-formatted name to an XDS object name (public object) by using the stringToXdsName( ) function call. This function builds an XDS public object that represents the distinguished name entered by the user.

Step 6 binds the session to the default server without credentials; username and password are not required.

In Step 7, the requested operation is performed by using XDS API functions calls. For an add operation, ds_add_entry( ) is performed; for a read operation, ds_read( ) is performed; and for a delete operation, ds_remove_entry( ) is performed. The read operation requires a series of XOM API om_get( ) function calls to extract the surname and phone number from the workspace. (For a detailed description of the XDS and XOM API function calls, refer to XOM Programming and XDS Programming.)

Step 8 and Step 9 are required for every XDS API application program in order to clean up before the program exits. The session is unbound from the server, and the public and private objects are released to the system that provided the memory allocated for them.