> DNU home > code projects page 1
Searching for Attribute Values - Source Code Details 1
DeveloperNet University Article

doSearch recieves an array of C strings in its bfr parameter and a user's last name in its theSurname parameter. The purpose of doSearch is to find all User objects in the target tree (specified by the DCK_TREE_NAME in gContext, initialized at login) that have a Surname (last name) approximately equal to the value in theSurname.

Upon its successful completion, doSearch returns a list of distinguished names for the found User objects in bfr.

All NDAP NDS C APIs require a reference to a context data structure as a parameter. The application-defined routine getRootContext( ) is called to obtain a context pointing to the root of the target tree and initialized to communicate over the authenticated connection that was obtained at login. Because the context points to root, it allows you to fully specify the object to be acted upon with the objectName parameter in your NDS calls. See Managing Contexts for more information on the code used in these examples to initialize client context.

Most NDS requests are composed in an NDS buffer which is then sent to the NDS tree to be handled. In the case of searching for objects with certain attribute/s value/s, NDS will need a DSV_SEARCH_FILTER type buffer that contains a search filter describing the search criteria.

Our example allocates two buffers, one to contain the search operation request which is initialized for a DSV_SEARCH_FILTER operation, and one to contain the response. The response buffer doesn't need to be initialized, NDS does that automatically when it satisfies the request.

See Managing NDS Buffers for more information on the application-defined getInitNDSBuffer routine which is used by these examples to allocate and initialize NDS buffers.



PREVIOUSblankTop of PageblankNEXT