Add(User: IMetabaseUser): IUserProfile;
User. The user, whose profile must be added to the collection.
The Add method adds the profile of the specified user to the collection.
User profiles are added to the appropriate collections automatically on the first use of the IMetabaseUser.Profile property.
The profiles can be added only to the repository profiles collection obtained in the IMetabase.Profiles property. The collection can be changed only by the repository administrator. The Add method can be used to add profiles of the users, which are created in the repository security manager.
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 := MS.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. The default email will be specified in the profile settings.
See also: