IUserProfiles.Add

Syntax

Add(User: IMetabaseUser): IUserProfile;

Parameters

User. The user, whose profile must be added to the collection.

Description

The Add method adds the profile of the specified user to the collection.

Comments

Profiles of the user are added to the appropriate collections automatically on the first reference to the IMetabaseUser.Profile property.

The profiles can be added only to the profile collection of the repository, obtained in the IMetabase.Profiles property. The collection can be changed only by the administrator of the repository. The Add method can be used to add profiles of the users which are created in the security manager of the repository.

Example

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

Sub UserProc;
Var
    MB: IMetabase;
    Sec: IMetabaseSecurity;
    User: IMetabaseUser;
    Data: ISecurityPackageUserData;
    Package: ISecurityPackage;
    PswCreds: IPasswordCredentials;
    Profs: IUserProfiles;
    Prof: IUserProfile;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    // Get license to be able to work with the security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    Sec := MB.Security;
    // Create a user
    User := Sec.AddUser("TestUser");
    User.FullName := "Test user";
    Sec.Policy.Privilege("LOGIN").Grant(User);
    Sec.Policy.Privilege("READ").Grant(User);
    // Set password
    Data := User.PackageData;
    Package := New StandardSecurityPackage.Create;
    PswCreds := Package.CreateCredentials(AuthenticationMode.Password) As IPasswordCredentials;
    PswCreds.Password := "Password";
    Data.Credentials := PswCreds;
    User.MustChangePasswordAtNextLogon := True;
    // Save changes
    Sec.Apply;
    // Check in license
    Lic := Null;
    // Add a user account to the collection of repository profiles
    Profs := MB.Profiles;
    Prof := Profs.Add(User);
    Prof := Prof.Edit;
    Prof.Email := User.Name + "@example.ru";
    Prof.Apply;
End Sub UserProc;

After executing the example a new repository user is created. The privileges will be granted to the user and the credentials will be specified. The user profile will also be added to the collection of repository profiles. In the settings of the profile the default email will be specified.

See also:

IUserProfiles