IMetabaseGroup.AddMember

Syntax

AddMember(Subject: ISecuritySubject);

AddMember(Prognoz.Platform.Interop.Metabase.ISecuritySubject);

Parameters

Subject. Security subject that needs to be added.

Description

The AddMember method adds the security subject that is passed as the Subject parameter in this group of users.

Example

To execute the example, add links to the Metabase, ForeSystem (for the Fore.NET example) system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MS: IMetabaseSecurity;
    Group: IMetabaseGroup;
    User: IMetabaseUser;
    Data: ISecurityPackageUserData;
    PS: IPasswordCredentials;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    
// Get license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    MS := MB.Security;
    Group := MS.Groups.Item(
0);
    
// Set a new user parameters
    User := MS.AddUser("USER_NEW");
    User.FullName := 
"First user";
    User.Description := 
"New platform user";
    Data := User.PackageData;
    PS := Data.Credentials 
As IPasswordCredentials;
    PS.Password := 
"Password";
    User.MustChangePasswordAtNextLogon := 
True;
    
// Add a new user to the first group
    Group.AddMember(User);
    
// Save changes
    MS.Apply;
    
// Check in license
    Lic := Null;
End Sub UserProc;

Imports Prognoz.Platform.Interop.Metabase;

Public Shared Sub Main(Params : StartParams);
Var
    MB: IMetabase;
    MS: IMetabaseSecurity;
    Group: IMetabaseGroup;
    User: IMetabaseUser;
    Data: ISecurityPackageUserData;
    PS: IPasswordCredentials;
    Lic: Object;
Begin
    MB := Params.Metabase;
    
// Get license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.lftAdm);
    MS := MB.Security;
    Group := MS.Groups.Item[
0];
    
// Set a new user parameters
    User := MS.AddUser("USER_NEW");
    User.FullName := 
"First user";
    User.Description := 
"New platform user";
    Data := User.PackageData;
    PS := Data.Credentials 
As IPasswordCredentials;
    PS.Password := 
"Password";
    User.MustChangePasswordAtNextLogon := 
True;
    
// Add a new user to the first group
    Group.AddMember(User);
    
// Save changes
    MS.Apply();
    
// Check in license
    Lic := Null;
End Sub;

After executing the example the USER_NEW new user will be created. This user is added into the first group created in a security manager. On the first login to the platform under this user, the request for password changing will be displayed.

See also:

IMetabaseGroup