IUserProfiles.Add

Fore Syntax

Add(User: IMetabaseUser): IUserProfile;

Fore.NET Syntax

Add(User: Prognoz.Platform.Interop.Metabase.IMetabaseUser): Prognoz.Platform.Interop.Metabase.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.

Fore Example

The specified example must be executed as the administrator of the repository.

Sub UserProc;
Var
    MB: IMetabase;
    Sec: IMetabaseSecurity;
    User: IMetabaseUser;
    Data: ISecurityPackageUserData;
    PS: IPasswordCredentials;
    Profs: IUserProfiles;
    Prof: IUserProfile;
Begin
    MB := MetabaseClass.Active;
    Sec := MB.Security;
    //Creating user
    User := Sec.AddUser("TestUser");
    User.FullName := "Test user";
    Sec.Policy.Privilege("LOG IN").Grant(User);
    Sec.Policy.Privilege("READING").Grant(User);
    Data := User.PackageData;
    PS := Data.Credentials As IPasswordCredentials;
    PS.Password := "Password";
    User.MustChangePasswordAtNextLogon := True;
    Sec.Apply;
    //Adding the profile of the user to the collection of profiles of the repository
    Profs := MB.Profiles;
    Prof := Profs.Add(User);
    Prof := Prof.Edit;
    Prof.Email := User.Name + "@example.ru";
    Prof.Apply;
End Sub UserProc;

On executing the example a new user of the repository will be 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.

Fore.NET Example

The specified procedure is an entry point for the .NET assembly. The example can be executed as the administrator of the repository.

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Sec: IMetabaseSecurity;
    User: IMetabaseUser;
    Data: ISecurityPackageUserData;
    PS: IPasswordCredentials;
    Profs: IUserProfiles;
    Prof: IUserProfile;
Begin
    MB := Params.Metabase;
    Sec := MB.Security;
    //Creating user
    User := Sec.AddUser("TestUser");
    User.FullName := "Test user";
    Sec.Policy.Privilege["LOG IN"].Grant(User);
    Sec.Policy.Privilege["READING"].Grant(User);
    Data := User.PackageData;
    PS := Data.Credentials As IPasswordCredentials;
    PS.Password := "Password";
    User.MustChangePasswordAtNextLogon := True;
    Sec.Apply();
    //Adding the profile of the user to the collection of profiles of the repository
    Profs := MB.Profiles;
    Prof := Profs.Add(User);
    Prof := Prof.Edit();
    Prof.Email := User.Name + "@example.ru";
    Prof.Apply();
End Sub;

On executing the example a new user of the repository will be 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