Search System Directory (QOKSCHD) API


  Required Parameter Group:


  Default Public Authority: *USE

  Threadsafe: No

The Search System Directory (QOKSCHD) API searches the system distribution directory and returns user information that matches the criteria input. It also is used to query fields in the directory. It is most useful when the system distribution directory is used as a repository for information about users, and can be used in a program to query this information.


Authorities and Locks

To search the system directory, *USE authority is required to the QOKSCHD API.


Required Parameter Group

Receiver variable
OUTPUT; CHAR(*)

The receiver variable that is to receive the information requested. You can specify the size of the area smaller than the format requested as long as you specify the length of the receiver variable correctly. As a result, the API returns only the data the area can hold.

Length of receiver variable
INPUT; BINARY(4)

The length of the receiver variable.

Format name of the receiver variable
INPUT; CHAR(8)

The format of the information returned. The possible format names are:


Function
INPUT; CHAR(10)

The function name of this request. The functions supported are:


Keep temporary resource indicator
INPUT; CHAR(1)

An indicator of whether to keep or delete the temporary resource that the search uses for search requests. This temporary resource keeps files open and other relevant information between calls. Performance will be better if this is done and you do multiple searches. If this API is called and this indicator is set to keep temporary resources, the last call should have the Function parameter set to *CLEANUP to close files and delete the resources.

The resource handle stores the information about the open files. When the search API is called again and the files have been left open, the resource handle needs to be passed. The resource handle differs from the continuation handle in that the resource handle saves information about open files. The same resource handle can be used to request different kinds of searches. If you are doing multiple types of searches, you do not want to do Function of *CLEANUP between the calls to the QOKSCHD API. Pass the same resource handle for these calls and it will make the searches perform faster. The continuation handle is used to continue the search with the same criteria because there are more users that match the search criteria. The continuation handle is documented in Field Descriptions.

Request variable
INPUT; CHAR(*)

The request variable that is the input buffer that requests the type of search to do.

Length of request variable
INPUT; BINARY(4)

The length of the request variable.

Format name of request variable
INPUT; CHAR(8)

The information requested. The possible format names are:


Error code
I/O; CHAR(*)

The structure in which to return error information. For the format of the structure, see Error code parameter.


SREQ0100 Format

The following table is the layout of the request variable, format SREQ0100, for requesting searches on the system directory user information.



SREQ0101 Format

The following table is the search request array, format SREQ0101. This format name is used as input in the request variable, SREQ0100, in the field, format name of the search request array.

This is an array of search fields. There is a maximum of 100 entries.

The first element that is entered in the search request array is considered to be the key for the search. This is important for performance because the more distinct the key, the faster the search. Records will be returned in the order of the field specified as the key.

A performance consideration that should be made when choosing the key value for the value to match field is whether the field will contain a wildcard character. The search key should contain fields that occur a minimum number of times on the system. For this reason, it is more efficient to specify a key search value that does not contain wildcard characters. A wildcard character at the end of a search key value does not affect performance.

The search is an AND of all of the input fields. It will be a complete match or a generic match if a wildcard character is used as the last character of the field value.



SREQ0102 Format

The following table is the array of fields to return, format SREQ102. This format name is used as input in the request variable, SREQ0100, in the field, format name of array of fields to return.

The SREQ0102 format provides for selecting a user controlled set of system distribution directory fields.



SREQ0103 Format

The following table is the array of special values representing the fields to be returned, format SREQ0103. This format name is used in the request variable, SREQ0100, in the field, format name of the array of fields to return.

The SREQ0103 format provides for selecting a predefined set of system distribution directory fields. The allowed special values are *SYSDIR, *ORNAME, and *SMTP. See Field Descriptions for a definition of the special value of fields to be returned field.



SREQ0200 Format

The following table is the layout of the request variable, format SREQ0200. This request returns the fields defined in the system distribution directory.



SRCV0100 Format

The following table is the layout of the receiver variable, format SRCV0100. The receiver variable is the output buffer for the search results. This format defines the structure of the receiver variable.

Fields returned in the receiver variable will be in the order as documented in System directory field names. All of the fields with a product ID of *IBM will precede any fields with a product ID other than *IBM. Also, fields with a product ID of *IBM that appear in the array of fields to return more than once will be returned one time.



SRCV0101 Format

The following table is the structure of the array of users returned, format SRCV0101. This format name is specified in the request variable structure, SREQ0100, in the field, format name of array of users to return.



SRCV0111 Format

The following table is the structure of the array of fields for each user returned, format SRCV0111. The format name is specified in the request variable structure, SREQ0100, in the field, format name of array of fields for each user returned. All fields requested are returned even if the fields are blank. The fields are returned in the order documented in System directory field names.



SRCV0112 Format

The following table is the structure of the array of fields for each user returned, format SRCV0112. The format name is specified in the request variable structure, SREQ0100, in the field, format name of array of fields for each user returned.

If you do not need user-defined fields or the field name and product ID, then request this format in SREQ0100 instead of SRCV0111, as it will save some overhead space. All fields requested are returned even if the fields are blank.

Format SRCV0120 tells the order in which the fields are returned. The order of the fields are always returned in the order as documented in System directory field names, but you may have a coding reason for needing to order the fields returned array.



SRCV0120 Format

The following table is the structure of the order of fields returned array, format SRCV0120. The format name is specified in the request structure, SREQ0100, in the field, format name of order of field names array returned.



SRCV0200 Format

The following table is the layout of the receiver variable, format SRCV0200. The receiver variable is the output buffer for the results from the system directory field name search request. The format name defines the structure of the receiver variable.



Array of Directory Field Names

The following table is the structure of the field name array. This format contains the field names of the type that was requested in SREQ0200.



Field Descriptions

Array of directory field names in the system distribution directory. The array of fields that are returned as a result of the search request array. This array contains the directory field name, product ID, directory field type, and the maximum field length.

Array of fields for each user that was requested. The actual data for each field for the user returned as a result of the match. See either SRCV0111 Format, or SRCV0112 Format for the structure of this array.

Array of fields to return. The field names that the user wants returned in the receiver variable for each user found that matches the search criteria. See either SREQ0102 Format, or SREQ0103 Format for the structure of this array. There is no maximum number of elements.

Array of users that match the search criteria. The array of users that matches the search criteria on the request. See SRCV0101 Format for the structure of this array.

Case of data input. The case of the data input. The valid values are:

CCSID of data input. The CCSID of the data input or a special value. The special values are:

Character set of data input. The character set of the data input. This field is used if the CCSID of data input is -1.

Character set or CCSID of the value. If the conversion of the data (convert receiver data indicator) was set to 0, this is the character set of the field value as it exists on the system. If the convert receiver indicator was set to 1, this is either a character set or CCSID depending on what was specified in the request variable for CCSID of data input. If the convert receiver data indicator was set to 2, this is the CCSID of the field value.

Code page of data input. The code page of the data input. This field is used if the CCSID of data input is -1.

Code page of the value. If the conversion of the data (convert receiver data indicator) was set to 0, this is the code page of the field value as it exists on the system. If the convert receiver indicator was set to 1, this is either a code page or CCSID depending on what was specified in the request variable for CCSID of data input. Otherwise, the code page is set to 0.

Compare value. The way to compare the value given with the field value in the system distribution directory entry. Only the value, 1 (equal), is currently supported.

Continuation handle (input). This allows you to continue to return data on a search if there was not enough space available to return all the entries that matched the search criteria on a previous search.

This value is 0 on the first search request. If you are continuing a search, this value needs to be set from the continuation handle (output) field.

The resource handle must be set if you are going to continue a search.

To use the continuation handle, you must keep the temporary resource space by setting the keep temporary resource indicator field to 1.

Continuation handle (output). An indicator for more directory entries available. The valid values are:

If this continuation handle is 0, either all the records that matched the search criteria were returned to this structure, or there were more records but the search files were not requested to be left open.

If the continuation handle is 1, there are more records available in the directory that match the search criteria, but there was no room available in the return structure. You may request more data by using this value in the request variable along with the resource handle.

Continuation handle for directory fields (input). Allows you to continue to return data on a search of directory fields if there was not enough space available to return all of the directory fields that matched the request.

This value is blank on the first request. If you are continuing a search, this value needs to be set from the continuation handle for directory fields (output) field.

Continuation handle for directory fields (output). Contains a value if there are more directory fields available for the search criteria requested. You may request more directory fields by using this value in the request variable field, continuation handle for directory fields (input).

Convert receiver data indicator. The option to convert the field values in the array of users returned for each user in the receiver variable.

The valid values are:

Data to search. The type of data to search on this system.

The valid values are:

Directory field name. Depending on the request in the SREQ0200 format, either an IBM-defined or a user-defined field. IBM® i system distribution directory field names have a product ID of *IBM. All other field names are for user-defined fields.

Directory field type. The following values can be returned for the field type and is meaningful only for user-defined fields:

See SRCV0200 Format for the field types for user-defined.

Field name. The field name can be an IBM-defined field name, or a user-defined field name. To determine the user-defined field names defined on the system, either use the Change System Directory Attributes (CHGSYSDIRA) command with F4, or retrieve the fields using the SREQ0200 format.

The following is a list of predefined field names that can be specified in the field name field of the array of search fields and the array of fields to return.

Notes:

  1. There is a maximum of 512 bytes for user-defined fields.

  2. There is a performance impact when a mixture of system directory field names, SMTP field names, and user-defined fields are specified in the search request array.

System directory field names

Note: This is the order in which the field names are returned when the return fields in order specified option is not 1 (0 is the default). The field is truncated so that ending blanks are not returned. This group of field names is the *SYSDIR group when the SREQ0103 format is used. See SREQ0103 Format for more information on the SREQ0103 format.

See SREQ0103 Format for more information on the SREQ0103 format.

Simple Mail Transfer Protocol (SMTP) field names:

These fields are the group of fields for the *SMTP special value in the SREQ0103 format.

See SREQ0103 Format for more information on the SREQ0103 format.

Field value. The value of the field.

Format name of array of fields for each user returned. The format name of the array of fields for each user returned. This is the specific structure for each user in either the SRCV0111 format or the SRCV0112 format. See either SRCV0111 Format, or SRCV0112 Format for more information on the array of fields for each user.

Format name of array of fields to return. The format name of the array of fields to return so that the fields of each user found matching the search criteria that is needed is known. The possible values are SREQ0102 and SREQ0103. See SREQ0102 Format, or SREQ0103 Format for more information on the array of fields to return for each user.

Format name of array of users to return in the receiver variable. The format name of the array of users to return after the search is complete. This is so the format to return the search results is known. The possible value is SRCV0101. See SRCV0101 Format for more information on the array of users returned.

Format name of order of field names array returned. The format name of the order of field names to be returned. Possible values are blank and SRCV0120. If the value is blank, the order of the field names array is not returned. The order of field names array is not returned if user-defined fields are requested as only the user-defined fields that exist for each user is returned and are not in any specified order.

Format name of the search request array. The format name of the search request array so that the format of the search request is known. The possible value is SREQ0101. See SREQ0101 Format for more information on the array of search fields.

Length of data for this user. The length of both the header information and the fields that are returned for the user.

Length of entry (including this field). The length of the entry in the array of all of the fields including this field.

Length of field value returned. The length, in bytes, of the field value. If this value is 0, there is no data in the field.

Length of value. If the length of the value is 0, this field is ignored on the search request. There must be at least one field in the search request array with a length of value greater than 0 and the value is not blank spaces.

The maximum length is 512.

Maximum field length. The maximum length of this directory field.

Number of bytes returned. The length of the data returned. If the receiver variable is not large enough to hold all of the data available, only the data that will fit in the space available is returned and this value will be less than the bytes available.

Number of directory entries returned. This is the number of directory entries that are returned in SRCV0101. It is the number of directory entries found as a result of the search request. If more directory entries are available but there was not enough space available in the SRCV0101 structure, the continuation handle will be 1. If all of the entries are returned, the continuation handle will be 0.

Number of directory field names returned. The number of elements in the field name array.

Number of directory fields. The total number of directory fields for the type of fields requested. If the continuation handler for directory fields is not blank, then there are more fields available.

Number of elements in the fields to return array. The number of fields to be returned for each user. These fields are returned in the receiver variable.

Number of elements in the search request array. The number of fields and values to match for the search request. The maximum number of elements allowed is 100.

Number of elements to return in the array of users to return. The number that should be used to return a fixed number of elements on a call to the API. The number of elements returned will be less than or equal to the number specified here. If the number returned is less than the number specified, then either all of the elements that met the criteria were returned or the size of the receiver variable could not hold the number specified.

The continuation handle will be set if more data exists after returning the number of elements specified for this parameter.

If this number is 0, the maximum number of elements possible is returned.

This field could be used to limit the run time of the API. For instance, it could be used to retrieve only the number of users needed to file a subfile page.

Number of fields returned. The number of fields returned for the user. Fields are returned even if blank.

Offset to array of fields to return. The offset, in bytes, to the array of fields to return.

Offset to order of fields returned array. The offset, in bytes, to the order of fields returned array. The value can be 0 if either the order of the fields is not needed or the user-defined fields are returned. This is requested in the SREQ0100 format. See SREQ0100 Format for more information on the offset to order of fields returned array.

Offset to the array of directory field names. The offset, in bytes, to the array of directory field names at the bottom of the SRCV0200 structure.

Offset to the first array of users entry. The offset, in bytes, to the array of users in the SRCV0100 structure. This is the offset to the first entry in the array of users that are returned that match the search criteria.

Offset to the search request array. The offset, in bytes, to the search request array in the SREQ0100 format. See SREQ0100 Format for more information on the offset to the search request array.

Order of fields returned array. The array of fields names of the order of the fields in the array of fields for each user (in either the SRCV0111 format or the SRCV0112 format) that is returned. For more information see SRCV0120 Format.

Product ID. A special value of *IBM i ndicates that the field is an IBM i system distribution directory field. A value of blank spaces indicates that there is no product ID associated with the field name.

An error will be signaled if:

Reserved. This is used to align the character set of the value field.

Resource handle. This value needs to be set from the output resource handle variable that was used as output in the receiver buffer from a previous search.

On the first call, this value needs to be blank.

To use the resource handle, you must specify to keep the temporary resources option on the previous search.

If you are continuing a search, the resource handle must be set from the output resource handle variable from a previous search of the same criteria.

If you are not continuing a search, the resource handle can be reused and the continuation handle will be set to 0. This will reuse the open files and temporary work areas.

If a resource handle is reused on another search, a continuation of a previous search is attempted using the same resource handle and the continuation is no longer valid for the previous search.

Return fields in order specified option. The option to return the fields in the order specified in the array of fields to return format. See SREQ0102 Format for the structure of this array. The valid values are:

Run verify indicator. The option to verify the input parameters. Running the verification process has the potential to increase the time it takes to run a search. If the verification flag is set off and no valid data is passed as input, unpredictable results may occur.

The purpose of this indicator is so verification does not have to be run when continuing the return of data, or when a search request is repeated.

The valid values are:

For the first search request, it is recommended that this value be 1.

Search request array. An array of search fields. There is a maximum of 100 entries. See SREQ0101 Format for the structure of this array.

The first element that is entered in the search request array is considered to be the key for the search. This is important for performance because the more distinct the key, the faster the search. Records will be returned in the order of the field specified as the key.

A performance consideration that should be made when choosing the key value is a value to match that contains wildcard characters. The search key should contain fields that occur a minimum number of times on the system. For this reason, it is more efficient to specify a key search value that does not contain wildcards.

The search is an AND of all the input fields. It will be a full match or a generic match if a wildcard character is used as the last character of the field value.

Special value of fields to be returned. This field selects a group of fields depending on the special value. The order of the field names returned in the SRCV0101 format is returned in the format, SRCV0120. The SRCV0120 format is optional. It is optional because the order of the field names is always the same, but it is given so you can programmatically find the order of fields returned.

The special values are:

Type of system distribution directory fields to return. The indicator for the type of system distribution directory fields that are defined on the system to be returned.

The possible values are:

Value to match. If a blank value is encountered, the API will ignore the field.

All values entered are monocased and converted to a common character set and code page before the search takes place. Therefore, the uppercase and lowercase characters are not distinguished, except for the SMTP user ID where it is distinguished. However, if the SMTP names are converted (CVTNAMSMTP command), the SMTP user ID is not distinguished because the SMTP fields are converted into user-defined fields.

A maximum of one wildcard character is allowed in the value to match field.

Wildcard character. The wildcard character indicates the wildcard character used for wildcard searches. An example of a wildcard character is an asterisk (*); however, the wildcard character can be anything you specify. If the character is encountered in the values to search on, that value indicates a wildcard search. This wildcard character will be in the CCSID or character set and code page (CHRID) that is used as input.

The wildcard character represents any number of characters (not just one character) in the search value to match. If a blank is used for a wildcard value, the API will not check for wildcards and the value will be checked specifically as input.

Note: The wildcard character field is a CHAR(4) because of DBCS and SBCS. In addition, for SBCS the wildcard character field is left-adjusted.


Error Messages



API introduced: V3R1

[ Back to top | Office APIs | APIs by category ]