ATTRIBUT.EXE

Overview

This sample is a console mode application that displays folder properties by using the Attribute filter. This filter is applied to a site container in order to enumerate specified properties of a machine of architecture type Personal Computer. This technique is used because it is faster than setting group filters and then retrieving specified machine group scalars.

Much of the code in this sample is written to be generic, so this is a good sample to use when you need to enumerate folders of unknown type.

The later portions of this code demonstrate techniques for handling specific types of folders. In general, when dealing with a folder that may contain many subfolders, it is recommended that you open and examine each subfolder in turn. For instance, when examining a domain folder, you should follow this technique, and you should not close the folder until all machines in the domain have been displayed. On the other hand, if the folder does not contain many subfolders, it is usually more efficient to open each subfolder, store the handles in a temporary list, and then close the folder.

Running the Program

ATTRIBUT.EXE is a console application that requires you to input the SQL Server name, Database name, SQL Logon ID, and Password. It then displays folder properties for the machines, starting in the root site. When it is finished displaying the folders, the program quits.

Functions

This program illustrates usage of the following SMS functions:

SmsAPIVer
SmsDataSourceConnect
SmsDataSourceDisconnect
SmsOpenContainer
SmsCloseContainer
SmsPopulate
SmsGetFolderCount
SmsGetNextFolder
SmsGetFolderType
SmsGetFolderID
SmsCloseFolder
SmsGetScalarCount
SmsGetNextScalar
SmsCreateFilter
SmsSetFilter
SmsCloseFilter
SmsAddToken

Program Flow

This program opens a site container, then constructs and applies an Attribute filter, a Site filter, and an Architecture filter. The code then populates the container with the folder for the root site, opens the folder, and displays the folder's properties (the folder type, and the number of scalars and subfolders the folder contains). Because the folder display function is recursive, calling this function with the root site folder will cause all folders in the site hierarchy to be displayed.