NewSnapshot: ISecuritySnapshot;
NewSnapshot: Prognoz.Platform.Interop.Metabase.ISecuritySnapshot;
The NewSnapshot method creates an object for reserve copying of security policy.
To save security policy to the *.pppolicy file, use the ISecuritySnapshot.SaveToFile property.
To execute the example, make sure that the C disk root directory contains the test.pppolicy file.
Add links to the Metabase, ForeSystem (for the Fore.NET example) system assemblies.
Sub UserProc;
Var
MB: IMetabase;
SE: IMetabaseSecurity;
SS: ISecuritySnapshot;
Log: ISecuritySnapshotLog;
Lic: Object;
Begin
MB := MetabaseClass.Active;
// Get license to work with security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
SE := MB.Security;
// Create an object for backup
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;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.ForeSystem;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
SE: IMetabaseSecurity;
SS: ISecuritySnapshot;
Log: ISecuritySnapshotLog;
Lic: Object;
Begin
MB := Params.Metabase;
// Get license to work with security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.lftAdm);
SE := MB.Security;
// Create an object for backup
SS := SE.NewSnapshot();
// Apply security policy from file
SS.ApplyFromFile("C:\test.pppolicy", Null);
Log := SS.Log;
System.Diagnostics.Debug.WriteLine("ApplyState SubjectName SubjectType Message");
While Not Log.Eof() Do
Select Case (Log.ApplyState As Integer)
Case 0 : System.Diagnostics.Debug.Write("None ");
Case 1 : System.Diagnostics.Debug.Write("Create ");
Case 2 : System.Diagnostics.Debug.Write("Change ");
Case 3 : System.Diagnostics.Debug.Write("Error ");
Case 4 : System.Diagnostics.Debug.Write("Deleted ");
End Select;
System.Diagnostics.Debug.Write(Log.SubjectName + " ");
Select Case (Log.SubjectType As Integer)
Case 1 : System.Diagnostics.Debug.Write("User ");
Case 2 : System.Diagnostics.Debug.Write("Group ");
End Select;
System.Diagnostics.Debug.Write(Log.Message);
Log.Next();
System.Diagnostics.Debug.WriteLine("");
End While;
// Save changes
SE.Apply();
// Check in license
Lic := Null;
End Sub;
After executing the example detailed information about the performed operations while applying security policy is displayed in the console.
See also: