AddGroup(GroupName: String): IMetabaseGroup;
AddGroup(System.String): Prognoz.Platform.Interop.Metabase.IMetabaseGroup;
GroupName. Name of group of users.
The AddGroup method creates a new user group.
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;
// Get license to work with security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
MS := MB.Security;
// Add a group of users and a user
Group := MS.AddGroup("Test group");
User := MS.AddUser("TestUser");
User.FullName := "Test user";
// Set privileges to user
MS.Policy.Privilege("ENTER").Grant(User);
MS.Policy.Privilege("READ").Grant(User);
// Set user password
Data := User.PackageData;
PS := Data.Credentials As IPasswordCredentials;
PS.Password := "Password";
User.MustChangePasswordAtNextLogon := True;
// Add a user to 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;
// Get license to work with security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.lftAdm);
MS := MB.Security;
// Add a group of users and a user
Group := MS.AddGroup("Test group");
User := MS.AddUser("TestUser");
User.FullName := "Test user";
// Set privileges to user
MS.Policy.Privilege["ENTER"].Grant(User);
MS.Policy.Privilege["READ"].Grant(User);
// Set user password
Data := User.PackageData;
PS := Data.Credentials As IPasswordCredentials;
PS.Password := "Password";
User.MustChangePasswordAtNextLogon := True;
// Add a user to group
Group.AddMember(User);
// Save changes
MS.Apply();
// Check in license
Lic := Null;
End Sub;
After executing the example a new group and a new user are created. The user is included to this group. Two privileges will be created for the user: the privilege for logging in the platform and the privilege for reading and opening objects. On the first login to the platform under this user, the request for password changing will be displayed.
See also: