ApplyWithInfo(InfoUserToUpdate: IMetabaseUsersUpdate): MetabaseSecurityApplyInformation;
InfoUserToUpdate. List of users that need updating.
NOTE. This input parameter must be empty.
The ApplyWithInfo method applies security policy and returns a list of the users, that need updating, if necessary.
In case if after application the method returns MetabaseSecurityApplyInformation.NoSysGrants, the InfoUserToUpdate parameter will contain a list of users to be updated. Applying security policy means saving all the changes, stored in security manager settings.
Executing the example requires that the security manager contains the TEST_USER user and the group of users named TEST GROUP.
Add links to the Metabase, ForeSystem (for the Fore.NET example) system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MS: IMetabaseSecurity;
Policy: IMetabasePolicy;
Group: IMetabaseGroup;
User: IMetabaseUser;
InfoUserToUpdate: IMetabaseUsersUpdate;
Result: Integer;
Lic: Object;
Begin
MB := MetabaseClass.Active;
// Get license to work with security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
MS := MB.Security;
Policy := MS.Policy;
// Get parameters of group of users and user
Group := MS.ResolveName("TEST GROUP") As IMetabaseGroup;
User := MS.ResolveName("TEST_USER") As IMetabaseUser;
// Grant privileges to user
Policy.Privilege("ENTER").Grant(User);
Policy.Privilege("READ").Grant(User);
// Add a user to group
Group.AddMember(User);
// Save changes and update the list of users
Result := MS.ApplyWithInfo(InfoUserToUpdate);
If Result = 1 Then
MS.UpdateUsers(InfoUserToUpdate);
End If;
// 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;
MS: IMetabaseSecurity;
Policy: IMetabasePolicy;
Group: IMetabaseGroup;
User: IMetabaseUser;
InfoUserToUpdate: IMetabaseUsersUpdate;
Result: Integer;
Lic: Object;
Begin
MB := Params.Metabase;
// Get license to work with security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.lftAdm);
MS := MB.Security;
Policy := MS.Policy;
// Get parameters of group of users and user
Group := MS.ResolveName("TEST GROUP") As IMetabaseGroup;
User := MS.ResolveName("TEST_USER") As IMetabaseUser;
// Grant privileges to user
Policy.Privilege["ENTER"].Grant(User);
Policy.Privilege["READ"].Grant(User);
// Add a user to group
Group.AddMember(User);
// Save changes and update the list of users
Result := MS.ApplyWithInfo(InfoUserToUpdate) As Integer;
If Result = 1 Then
MS.UpdateUsers(InfoUserToUpdate);
End If;
// Check in license
Lic := Null;
End Sub;
After executing the example, the TEST_USER user will be added to the test group of users with the specified privileges.
See also: