1.2 Buffer Management

Applications access eDirectory services through functions that might require input and output parameters in a complex variety of data configurations. For example, some functions require input parameters of multiple objects with multiple attributes assigned multiple values. Other functions return parameters that are equally complex.

To accommodate the data requirements of the various functions and to provide a flexible client interface, most eDirectory functions pass input and output parameters through specially defined local buffers. Therefore, an understanding of buffer management is essential to developing eDirectory-aware programs.

In general, buffer management involves the following steps:

  1. Allocate any input and output buffers required by an operation.

  2. Initialize any input buffers.

  3. Place any input parameters that define your operation into the input buffer.

  4. Execute the request.

  5. After the operation is complete, retrieve any results from the output buffer.

  6. Clean up by deallocating buffers you no longer need.

The following sections describe buffer size, initialization, message length, allocation types, required search buffers, and then list the functions used in buffer management.

See Also:

1.2.1 Buffer Size in eDirectory

To allocate an input or output buffer, call NWDSAllocBuf. All input and output buffers are of type Buf_T. You must specify the size of the buffer to allocate. Rather than trying to determine the exact buffer size required for a particular operation, it’s usually more convenient to define a standard buffer length that will be adequate for most operations.

The size of an output buffer affects how the server processes a request. A server will continue adding data to the buffer until the buffer is full or the request is satisfied. Consequently, if you use a very large input buffer, you may wait longer for initial results than if you use a small buffer. At the same time, a larger buffer may require fewer transmissions than a smaller buffer. The DEFAULT_MESSAGE_LEN constant is defined as 4 KB.

1.2.2 Initialization Operations for eDirectory Input Buffers

Only input buffers (also called request buffers) need to be initialized with an operation type. Output buffers (also called result buffers) do not need to be initialized. Input buffers are used in read and search operations to restrict the operation to a list of classes or attributes. They are also used when creating class or attribute definitions and when adding objects to or modifying objects in the eDirectory tree. See Section 5.3, Buffer Operation Types and Related Functions for a list of operation types for buffer initialization.

Once the buffer is initialized, it is ready to receive data. However, you cannot put data directly into the buffer. eDirectory has a set of specialized functions for placing the data into the input buffer.

1.2.3 eDirectory Buffer Allocation and Initialization Functions

The following functions are used to allocate input and output buffers and to initialize the input buffers.

NWDSAllocBuf

Allocates a Buf_T structure and the requested number of bytes.

NWDSInitBuf

Initializes a Buf_T structure for input.

NWDSFreeBuf

Destroys a Buf_T structure and frees the memory allocated to it.

1.2.4 eDirectory Input Buffer Functions

The following functions are used to set up the input or request buffers with the information that limits the scope of the request from all items of a type to the items listed in the request buffer.

NWDSBeginClassItem

Begins the insertion of a class definition into an input buffer.

NWDSPutAttrName

Inserts the name of an attribute into an input buffer.

NWDSPutAttrVal

Inserts an attribute value into an input buffer.

NWDSPutAttrNameAndVal

Inserts the name of an attribute and its value into an input buffer.

NWDSPutChange

Inserts a change record into an input buffer.

NWDSPutChangeAndVal

Inserts a change record and an attribute value into an input buffer.

NWDSPutClassItem

Inserts a class item into an input buffer.

NWDSPutClassName

Inserts the name of an object class into an input buffer.

NWDSPutSyntaxName

Inserts the name of a syntax into an input buffer.

NWDSPutFilter

Inserts a search filter expression tree into an input buffer.

1.2.5 eDirectory Output Buffer Functions

The following functions are used to retrieve information from output or result buffers.

NWDSComputeAttrValSize

Returns the size of the next attribute value in a result buffer.

NWDSGetAttrCount

Returns the number of attributes in a result buffer.

NWDSGetAttrDef

Returns the next attribute definition in a buffer.

NWDSGetAttrName

Returns the next attribute and the number of associated values in a result buffer.

NWDSGetAttrVal

Returns the next value of an attribute in a result buffer.

NWDSGetClassDef

Returns the next class definition in a result buffer.

NWDSGetClassDefCount

Returns the number of class definitions in a result buffer.

NWDSGetClassItem

Returns the next item of a class item list in a result buffer.

NWDSGetClassItemCount

Returns the number of items in a class item list in a result buffer.

NWDSGetObjectCount

Returns the number of objects in a result buffer.

NWDSGetObjectName

Returns the next object name in a result buffer.

NWDSGetPartitionInfo

Returns the next partition information structure in a result buffer.

NWDSGetServerName

Returns the name of the server and the number of partition names in a result buffer.

NWDSGetSyntaxCount

Returns the number of syntax definitions in a result buffer.

NWDSGetSyntaxDef

Returns the next syntax definition in a result buffer.