PredefinedPrivilege(Predefined: MetabasePolicyPredefinedPrivilege): IPrivilege;
The PredefinedPrivilege property returns parameters of a specified privilege.
To execute the example, add links to the Metabase, ForeSystem (for the Fore.NET example) system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MS: IMetabaseSecurity;
Policy: IMetabasePolicy;
Priv: IPrivilege;
User: ISecuritySubject;
Lic: Object;
Begin
MB := MetabaseClass.Active;
// Get license to work with security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
MS := MB.Security;
Policy := MS.Policy;
// Add a privilege holder
Priv := Policy.PredefinedPrivilege(MetabasePolicyPredefinedPrivilege.ReadAnyObject);
User := MS.ResolveName("USER") As ISecuritySubject;
Priv.Grant(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;
Policy: IMetabasePolicy;
Priv: IPrivilege;
User: ISecuritySubject;
Lic: Object;
Begin
MB := Params.Metabase;
// Get license to work with security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.lftAdm);
MS := MB.Security;
Policy := MS.Policy;
// Add a privilege holder
Priv := Policy.PredefinedPrivilege[MetabasePolicyPredefinedPrivilege.metpolprepriReadAnyObject];
User := MS.ResolveName("USER") As ISecuritySubject;
Priv.Grant(User);
// Save changes
MS.Apply();
// Check in license
Lic := Null;
End Sub;
After executing the example, the specified USER user becomes holder of the Read and Open All Objects privilege.
See also: