AddMember(Subject: ISecuritySubject);
Subject. Security subject that needs to be added.
The AddMember method adds the security subject that is passed as the Subject parameter in this group of users.
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;
// Check out 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;
Imports Prognoz.Platform.Interop.ForeSystem;
…
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;
// Check out 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: