IMetabaseSecurity.AddGroup

Syntax

AddGroup(GroupName: String): IMetabaseGroup;

Parameters

GroupName. Name of group of users.

Description

The AddGroup method creates a new group of users.

Example

To execute the example, add a link to the Metabase system assembly.

Sub UserProc1;
Var
    MB: IMetabase;
    MS: IMetabaseSecurity;
    Group: IMetabaseGroup;
    User: IMetabaseUser;
    Data: ISecurityPackageUserData;
    Package: ISecurityPackage;
    PswCreds: IPasswordCredentials;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    // Get license to be able to work with the security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    MS := MB.Security;
    // Add a group of users and a user
    Group := MS.AddGroup("Test group");
    User := MS.AddUser("TestUser");
    User.FullName := "Test user";
    // Set user privileges
    MS.Policy.Privilege("LOGIN").Grant(User);
    MS.Policy.Privilege("READ").Grant(User);
    MS.Policy.Privilege("LOGIN TO OBJECT NAVIGATOR").Grant(User);
    // Set user password
    Data := User.PackageData;
    Package := New StandardSecurityPackage.Create;
    PswCreds := Package.CreateCredentials(AuthenticationMode.Password) As IPasswordCredentials;
    PswCreds.Password := "Password";
    Data.Credentials := PswCreds;
    User.MustChangePasswordAtNextLogon := True;
    // Add user to group
    Group.AddMember(User);
    // Save changes
    MS.Apply;
    // Check in license
    Lic := Null;
End Sub UserProc1;

After executing the example a new group and a new user are created. The user is included in this group. Two privileges will be created for the user: the privilege for logging in the platform and the privilege for reading and opening objects. On the first login to the platform under this user, the request for password change will be displayed.

See also:

IMetabaseSecurity