Creating Filters

    To create a filter
  1. Use the SmsCreateFilter function to create a filter for use on the container. After your application uses the SmsCreateFilter function to create a filter, the filter is empty, that is, it has no tokens set. Your application should use the filter functions to set the tokens for the new filter.
  2. Configure the filter by adding tokens to the filter. There are two types of tokens: expression tokens and control tokens.

    An expression token defines how to search for objects that have a specified relationship to a specified value for a specified attribute. A TOKEN structure is used to specify the criterion for the expression. Note that each filter type has its own set of attribute types that can be evaluated. For example, a PACKAGE_FILTER evaluates only the package type (example: package type is equal to Workstation), whereas a MACHINE_FILTER evaluates any attribute for any group for a particular architecture (example: Processor Name attribute of the MICROSOFT|PROCESSOR|1.0 group class for the Personal Computer architecture is like 486). In addition, each filter type requires specific members of the TOKEN structure to be assigned. For example, to add an expression token to a PACKAGE_FILTER, the TOKEN structure must specify the szName, DwOp, and szValue members. For a MACHINE_FILTER, the TOKEN structure must specify the szArchitecture, szGroupClass, szAttributeName, DwOp, and szValue members.

    For information about the tokens required for each filter type, see the appropriate topic under Filter Types.

    A control token can be a logical operator or parentheses. A logical operator (AND and OR) defines the relationship between two adjacent expressions. Parentheses enable expressions to be grouped together. A TOKEN structure is used to specify the type of logical operator.

    To add expression tokens to a filter, use the SmsAddToken function. When an expression token is added to a filter, a control token for a logical operator is also added at the same time.

    To delete, exclude, group, or ungroup tokens within a filter, use the SmsManipulateTokens function.

    To get information about an existing token in a filter, use the SmsGetToken function.

    To get the count of existing tokens in a filter, use the SmsGetTokenCount function.

To use the filter, your application must use the SmsSetFilter function to apply the filter to a container that supports the filter type. After applying the filter to a container, your application must use the SmsPopulate function to query the site database for folders that meet the criteria set by the filters applied to the container.