IMetabaseSecurity.NewSnapshot

Syntax

NewSnapshot: ISecuritySnapshot;

Description

The NewSnapshot method creates an object for security policy backup.

Comments

To save security policy to the *.pppolicy file, use the ISecuritySnapshot.SaveToFile property.

Example

To execute the example, make sure that the root of the C drive contains the test.pppolicy file.

Add a link to the Metabase system assembly.

Sub UserProc;
Var
    MB: IMetabase;
    SE: IMetabaseSecurity;
    SS: ISecuritySnapshot;
    Log: ISecuritySnapshotLog;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    
// Check out license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    SE := MB.Security;
    
// Create a backup object
    SS := SE.NewSnapshot;
    
// Apply security policy from file
    SS.ApplyFromFile("C:\test.pppolicy");
    Log := SS.Log;
    Debug.WriteLine(
"ApplyState SubjectName SubjectType Message");
    
While Not Log.Eof Do
        
Select Case (Log.ApplyState As Integer)
            
Case 0 : Debug.Write("None ");
            
Case 1 : Debug.Write("Create ");
            
Case 2 : Debug.Write("Change ");
            
Case 3 : Debug.Write("Error ");
            
Case 4 : Debug.Write("Deleted ");
        
End Select;
        Debug.Write(Log.SubjectName + 
" ");
        
Select Case (Log.SubjectType As Integer)
            
Case 1 : Debug.Write("User ");
            
Case 2 : Debug.Write("Group ");
        
End Select;
        Debug.Write(Log.Message);
        Log.Next;
        Debug.WriteLine(
"");
    
End While;
    
// Save changes
    SE.Apply;
    
// Check in license
    Lic := Null;
End Sub UserProc;

After executing the example the console displays detailed information about the executed operations while applying security policy.

See also:

IMetabaseSecurity