IMetabaseSecurity.ApplyWithInfo

Syntax

ApplyWithInfo(InfoUserToUpdate: IMetabaseUsersUpdate): MetabaseSecurityApplyInformation;

Fore.NET Syntax

ApplyWithInfo(InfoUserToUpdate: Prognoz.Platform.Interop.Metabase.IMetabaseUsersUpdate) : Prognoz.Platform.Interop.Metabase.MetabaseSecurityApplyInformation

Parameters

InfoUserToUpdate. List of users that need updating. This parameter has to be empty when entering.

Description

The ApplyWithInfo method applies security policy and returns a list of the users, that need updating, if necessary.

Comments

If the method returns "MetabaseSecurityApplyInformation.NoSysGrants" after applying, the InfoUserToUpdate parameter contains a list of users that need updating. Applying security policy means saving all the changes, stored in security manager settings.

Fore Example

To execute the example, add the Metabase system assembly to the module.

Sub UserProc;
Var
    MB: IMetabase;
    Sec: IMetabaseSecurity;
    Policy: IMetabasePolicy;
    Group: IMetabaseGroup;
    User: IMetabaseUser;
    PS: IPasswordCredentials;
    InfoUserToUpdate: IMetabaseUsersUpdate;
    Result: Integer;
Begin
    MB := MetabaseClass.Active;
    Sec := MB.Security;
    Policy := Sec.Policy;
    Group := Sec.ResolveName("A TEST GROUP"As IMetabaseGroup; //.AddGroup("A test group");
    User := Sec.ResolveName("TESTUSER"As IMetabaseUser;
    Policy.Privilege("ENTER").Grant(User);
    Policy.Privilege("READING").Grant(User);
    Group.AddMember(User);
    Result := Sec.ApplyWithInfo(InfoUserToUpdate);
    If Result = 1 Then
        Sec.UpdateUsers(InfoUserToUpdate);
    End If;
End Sub UserProc;

After executing the example a user is added to the specified users group and gets the assigned privileges.

Fore.NET Example

The specified procedure is an entry point for the .NET assembly.

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Sec: IMetabaseSecurity;
    Policy: IMetabasePolicy;
    Group: IMetabaseGroup;
    User: IMetabaseUser;
    PS: IPasswordCredentials;
    InfoUserToUpdate: IMetabaseUsersUpdate;
    Result: Integer;
Begin
    MB := Params.Metabase;
    Sec := MB.Security;
    Policy := Sec.Policy;
    Group := Sec.ResolveName("A TEST GROUP"As IMetabaseGroup;
    User := Sec.ResolveName("TESTUSER"As IMetabaseUser;
    Policy.Privilege["ENTER").Grant(User);
    Policy.Privilege["READING"].Grant(User);
    Group.AddMember(User);
    Result := Sec.ApplyWithInfo(InfoUserToUpdate) As Integer;
    If Result = 1 Then
        Sec.UpdateUsers(InfoUserToUpdate);
    End If;
End Sub;

After executing the example a user is added to the specified users group and gets the assigned privileges.

See also:

IMetabaseSecurity