Share via


Accessing Classification Properties

Enumerating FSRM classification properties is easily done using the FsrmClassificationManager object.

All interfaces required to access and manage properties are defined in SrmLib.dll found in the System32 directory of Windows Server 2008 R2 and later. This library will have to be added as a reference to projects that attempt to interface with the classification infrastructure. All the relevant interfaces are in the Microsoft.Storage namespace.

Querying classification property definitions

Querying the classification property definitions on a server has to be done via APIs. It follows this pattern:

This snippet demonstrates enumerating classification properties.

FsrmClassificationManager cls = new FsrmClassificationManager();
 
ICollection c = cls.EnumPropertyDefinitions
(_FsrmEnumOptions.FsrmEnumOptions_None);
foreach (IFsrmPropertyDefinition p in c)
{
/*...*/
}

PowerShell
$cls = New-Object -com Fsrm.FsrmClassificationManager
$cls.EnumPropertyDefinitions()

Retrieving a classification property by name

If the name of a property is known, the property definition can be retrieved using the GetPropertyDefinition method.

Note

This is the Name property of the property definition, not the DisplayName property.

This snippet demonstrates retrieving a classification property.

FsrmClassificationManager cls = new FsrmClassificationManager();
 
IFsrmPropertyDefinition p = cls.GetPropertyDefinition("<Name>");

PowerShell
$cls = New-Object -com Fsrm.FsrmClassificationManager
$cls.GetPropertyDefinition("<Name>")

Retrieving classification properties on a file

To query the classification properties on a file there are two mechanisms available:

  • If the name of the property is known, the GetFileProperty method can be used to specify the exact property to get.

    Note

    This is the Name property of the property definition, not the DisplayName property.

  • Otherwise, the EnumFileProperties method can retrieve all properties known for a file.

In either case, the mechanism to do this follows this pattern:

This snippet demonstrates retrieving classification properties on a file.

FsrmClassificationManager cls = new FsrmClassificationManager();
            
/* The _FsrmGetFilePropertyOptions.FsrmGetFilePropertyOptions_None
* option signals that if the file has not been 
* classified yet, any applicable rules should be applied
* to classify the file now.
*/
IFsrmProperty p = cls.GetFileProperty(@"c:\data\data.txt", 
                                      "Business Impact",
                                      _FsrmGetFilePropertyOptions.FsrmGetFilePropertyOptions_None);
if (p.Value == "HBI")
{
/*...*/
}
            
/* The _FsrmGetFilePropertyOptions.FsrmGetFilePropertyOptions_NoRuleEvaluation
* option signals that only properties stored in the 
* cache, or one of the storage modules should be 
* returned. If the file has not been classified yet, no
* properties will be returned.
*/
ICollection c = cls.EnumFileProperties(@"c:\data\data.txt", 
                                      _FsrmGetFilePropertyOptions.FsrmGetFilePropertyOptions_NoRuleEvaluation);
foreach (IFsrmProperty p in c)
{
/*...*/
}

PowerShell
$cls = New-Object -com Fsrm.FsrmClassificationManager
$p = $cls.GetFileProperty("c:\data\data.txt", "<Name>", 0)
$c = $cls.EnumFileProperties("c:\data\data.txt", "<Name>", 1)

Setting a property on a file

Setting a property on a file is very similar using the SetFileProperty method.

Note

This is the Name property of the fille property, not the DisplayName property.

This snippet demonstrates setting a property on a file.

FsrmClassificationManager cls = new FsrmClassificationManager();
cls.SetFileProperty(@"c:\data\data.txt", "<Name>", "<Value>");

PowerShell
$cls = New-Object -com Fsrm.FsrmClassificationManager
$p = $cls.SetFileProperty("c:\data\data.txt", "<Name>", "<Value>")

Property type representations

Values for properties are always Unicode strings. The following conventions should be used when retrieving or setting classification properties:

Property Type Unicode String Representation
String
Standard representation of value
Integer
Standard representation of value
Ordered List
Standard representation of value
Boolean
"1" for yes/true and "0" for no/false
Date
Standard representation of a decimal 64 bit FILETIME value
Multi-choice
Standard representation of values separated by '|'
Multi-string
Standard representation of values separated by '|'

Using FSRM

FsrmClassificationManager

IFsrmClassificationManager

IFsrmClassificationManager::EnumFileProperties

IFsrmClassificationManager::EnumPropertyDefinitions

IFsrmClassificationManager::GetFileProperty

IFsrmClassificationManager::GetPropertyDefinition

IFsrmClassificationManager::SetFileProperty

IFsrmPropertyDefinition