IUserProfiles.Add

Syntax

Add(User: IMetabaseUser): IUserProfile;

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.

Example

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

Sub UserProc;
Var
    MB: IMetabase;
    Sec: IMetabaseSecurity;
    User: IMetabaseUser;
    Data: ISecurityPackageUserData;
    PS: IPasswordCredentials;
    Profs: IUserProfiles;
    Prof: IUserProfile;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    
// Check out license to work with 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);
    Data := User.PackageData;
    PS := Data.Credentials 
As IPasswordCredentials;
    PS.Password := 
"Password";
    User.MustChangePasswordAtNextLogon := 
True;
    
// Save changes
    Sec.Apply;
    
// Check in license
    Lic := Null;
    
// Add 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;

Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.ForeSystem;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Sec: IMetabaseSecurity;
    User: IMetabaseUser;
    Data: ISecurityPackageUserData;
    PS: IPasswordCredentials;
    Profs: IUserProfiles;
    Prof: IUserProfile;
    Lic: Object;
Begin
    MB := Params.Metabase;
    
// Check out license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.lftAdm);
    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);
    Data := User.PackageData;
    PS := Data.Credentials 
As IPasswordCredentials;
    PS.Password := 
"Password";
    User.MustChangePasswordAtNextLogon := 
True;
    
// Save changes
    Sec.Apply();
    
// Check in license
    Lic := Null;
    
// Add 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;

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