Grant(Subject: ISecuritySubject);
Subject is a security subject for which the privilege should be dispensed.
The Grant method grants the privilege to the security subject that is passed by the Subject parameter.
Sub Main;
Var
MB: IMetabase;
Sec: IMetabaseSecurity;
Policy: IMetabasePolicy;
Group: IMetabaseGroup;
User: IMetabaseUser;
Data: ISecurityPackageUserData;
PS: IPasswordCredentials;
Begin
MB := MetabaseClass.Active;
Sec := MB.Security;
Policy := Sec.Policy;
Group := Sec.AddGroup("A test group");
User := Sec.AddUser("TESTUSER");
User.FullName := "A test user";
Policy.Privilege("Entry").Grant(User);
Policy.Privilege("Reading").Grant(User);
Data := User.PackageData;
PS := Data.Credentials As IPasswordCredentials;
PS.Password := "Password";
User.MustChangePasswordAtNextLogon := True;
Group.AddMember(User);
Sec.Apply;
End Sub Main;
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: