ApplyWithInfo(InfoUserToUpdate: IMetabaseUsersUpdate): MetabaseSecurityApplyInformation;
InfoUserToUpdate. List of users who should be updated.
NOTE. This input parameter must be empty.
The ApplyWithInfo method applies security policy and returns the list of the users who should be updated if required.
If after application the method returns MetabaseSecurityApplyInformation.NoSysGrants, the InfoUserToUpdate parameter will contain a list of users who should 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 user group named TEST_GROUP.
Add a link to the Metabase system assembly.
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 the security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
MS := MB.Security;
Policy := MS.Policy;
// Get parameters of user group and user
Group := MS.ResolveName("TEST_GROUP") As IMetabaseGroup;
User := MS.ResolveName("TEST_USER") As IMetabaseUser;
// Grant privileges to user
Policy.Privilege("LOGIN").Grant(User);
Policy.Privilege("READ").Grant(User);
// Add user to group
Group.AddMember(User);
// Save changes and refresh list of users
Result := MS.ApplyWithInfo(InfoUserToUpdate);
If Result = 1 Then
MS.UpdateUsers(InfoUserToUpdate);
End If;
// Check in license
Lic := Null;
End Sub UserProc;
After executing the example the specified user is added to the test user group with the specified privileges.
See also: