Package Filters (PACKAGE_FILTER)

A package filter specifies the packages that are retrieved for a package container. A package filter enables your application to retrieve packages with workstation, sharing, or inventory properties set. If no package filter is set on a package container, all packages in the site database are retrieved for the container. Package filters can only be applied to package containers.

Using the SmsAddToken function, your application can add tokens to a package filter. Each expression token represents an attribute. For package filters, the tokens can be connected by using an OP_OR or OP_AND control token.

The TOKEN structure that contains the expression token must have the following members:

szName
A string that specifies the name of the package property to be evaluated by the expression.

Currently, only one property can be evaluated: PackageType. PackageType specifies that the type of package is being evaluated.

DwOp
A DWORD value that specifies the operator used to evaluate the expression.

For package filters, this operator can only be QOP_STR_EQ.

SzValue
A string that specifies the value to be evaluated for the property specified by szName.

There are three values available for PackageType: Workstation, Server, and Inventory.

For example, if PackageType is set for szName, the string "Workstation" would specify a package with Workstation properties set.

For example, your application could create a package filter with a token that specifies a PackageType of Workstation. Your application could set this filter as the only filter on a package container. When your application populates the container, it contains folders that represent all packages that have Workstation properties defined.

Example

// Function to add a token to a package filter so that
// the filter retrieves the package folders that
// are available for Run Command On Workstation jobs.

SMS_STATUS AddTokenToPackageFilter(HANDLE hFilter) 
                         //  Handle to package filter.
{
SMS_STATUS stat;
TOKEN Token;
// Clear the Token structure.
memset( &Token, 0, sizeof (TOKEN) );

// Set the expression token to 
// szName = "PackageType"
// dwOp = QOP_STR_EQ
// szValue = "Workstation"

// Set the package property.
strcpy( Token.szName, "PackageType");
// Set the operator to string equals.
Token.dwOp = QOP_STR_EQ;
// Set the type of package.
strcpy( Token.szValue, "Workstation"); 

// Add the token to the filter.
stat = SmsAddToken( hFilter, // Specifies the handle to filter.
                    OP_OR,  // Use the OR control token to 
                             // add a token to the package filter.
                    &Token,  // Specifies the structure containing
                             // the expression token.
                    AT_END   // Adds the token to the end of 
                             // the filter.
                  );


if (stat == SMS_OK)    
    printf("The token was successfully added to the filter.\n");
else 
    printf("SmsAddToken error: %d\n", stat);

return stat;
}