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 group of users 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;
// Check out 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;
After executing the example the TEST_USER user will be added to the test group of users with the specified privileges.
See also: