MDAC 2.5 SDK - Technical Articles


 

SEC_OBJECT

The SEC_OBJECT structure contains a counted array of SEC_OBJECT_ELEMENT structures that are used to identify the object on which security is being applied.

typedef struct _SEC_OBJECT {
   DWORD                   cObjects;
   SEC_OBJECT_ELEMENT*     prgObjects;
} SEC_OBJECT;
Element Description
cObjects The number of elements in the array pointed to by prgObjects.
prgObjects Array of SEC_OBJECT_ELEMENT structures that identify a hierarchy of objects.

Comments

The array of SEC_OBJECT_ELEMENT structures is used to identify the specific object or type of object on which security is being applied. Each structure represents a deeper level in the hierarchy of object. The SEC_OBJECT_ELEMENT structure at index 0 represents the broadest object. The structure at index 1 represents a specific object contained within the first object, and so on.

For example, to apply security to a column object, the SEC_OBJECT structure may contain three SEC_OBJECT_ELEMENT structures, as follows:

SEC_OBJECT soColumn;
soColumn.cObjects = 3;
soColumn.prgObjects = CoTaskMemAlloc(3 * sizeof(SEC_OBJECT_ELEMENT));

The first item indicates the schema identified by name, as follows:

soColumn.prgObjects[0].guidObjectType = DBOBJECT_SCHEMA;
soColumn.prgObjects[0].ObjectID.eKind = DBKIND_NAME;
soColumn.prgObjects[0].ObjectID.pwszName = L"TheSchema";

The second item indicates the table within the schema by name, as follows:

soColumn.prgObjects[1].guidObjectType = DBOBJECT_TABLE;
soColumn.prgObjects[1].ObjectID.eKind = DBKIND_NAME;
soColumn.prgObjects[1].ObjectID.pwszName = L"TheTable";

The third item identifies the column in the table by property ID only, as follows:

soColumn.prgObjects[2].guidObjectType = DBOBJECT_COLUMN;
soColumn.prgObjects[2].ObjectID.eKind = DBKIND_PROPID;
soColumn.prgObjects[2].ObjectID.ulPropid = 3;

A SEC_OBJECT initialized this way would indicate the fourth column (from a zero-based index) in the table named "TheTable" in the schema named "TheSchema" in the currently initialized data source object.

By using an array to progressively specify the object on which security is being applied, a single SEC_OBJECT structure can uniquely identify an object at any depth in the hierarchy of objects within the data source object.

See also

SEC_OBJECT_ELEMENT