OnSubjectApply(ApplyState: ApplyStateType; Subject: ISecuritySubject; Var State: Integer);
ApplyState. A type of the security subject restoring.
Subject. A security subject.
State. A state.
The OnSubjectApply method implements an event that takes place while restoring the users/groups.
Class CSnapBack : SecuritySnapshotCallback
Public Constructor Create;
Begin
End Constructor Create;
Public Sub OnSubjectApply(ApplyState: ApplyStateType; Subject: ISecuritySubject; Var State: Integer);
Begin
Debug.WriteLine("OnSubjectApply " + Subject.Name + " " + CultureInfo.Current.FormatTime(DateTime.Now) + " - " + ApplyState.ToString);
End Sub OnSubjectApply;
Public Sub OnOperation(ApplyOperation: SnapshotApplyOperationType; Var State: Integer);
Begin
Debug.WriteLine("OnOperation: " + CultureInfo.Current.FormatTime(DateTime.Now) + " - " + ApplyOperation.ToString);
End Sub OnOperation;
End Class CSnapBack;
Sub Main;
Var
MB : IMetabase;
SE : IMetabaseSecurity;
SS : ISecuritySnapshot;
SSL : ISecuritySnapshotLog;
i : Integer;
CallBack : CSnapBack;
Begin
MB := MetabaseClass.Active;
SE := MB.Security;
SS := SE.NewSnapshot;
CallBack := New CSnapBack.Create;
SS.ApplyFromFile("C:\test.pppolicy", CallBack);
SSL := SS.Log;
For i := 0 To SSL.Fields.Count - 1 Do
Debug.Write((SSL.Fields.Item(i).Name As String) + " ");
End For;
Debug.WriteLine("");
While Not SSL.Eof Do
For i := 0 To SSL.Fields.Count-1 Do
If SSL.Fields.Item(i).Name = "APST" Then
Select Case (SSL.Fields.Item(i).Value 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;
Else
Debug.Write((SSL.Fields.Item(i).Value As String) + " ");
End If;
End For;
SSL.Next;
Debug.WriteLine("");
End While;
End Sub Main;
After executing the example information about performed operations when applying security policy, as well as detailed list of groups/users and manipulations, performed with them, are displayed in the console window.
See also: