ItemByClassId(ClassId: MetabaseObjectClass): IMetabaseClassSecurityDescriptor;
ClassId. Object type.
The ItemByClassId property returns parameters of security descriptor by object type.
The property is read-only.
To execute the example make sure that security manager contains the USER user and administrator is allowed to execute all operations with the Express Report object type on setting up parameters of access control on the Discretionary Access Control window.
Add links to the Metabase, ForeSystem (for Fore.NET example) system assemblies.
Sub UserProc;
Var
MB: IMetabase;
SecDescrs: IMetabaseClassesSecurityDescriptors;
ClassSecDescr: IMetabaseClassSecurityDescriptor;
MS: IMetabaseSecurity;
SecDescr: ISecurityDescriptor;
Lic: Object;
Type: AceType;
Sid: ISid;
Begin
MB := MetabaseClass.Active;
// Check out license to work with security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
MS := MB.Security;
// Get security parameters of the Express Report object type
SecDescrs := MS.MetabaseClassesSecurityDescriptors;
ClassSecDescr := SecDescrs.ItemByClassId(MetabaseObjectClass.KE_CLASS_EXPRESSREPORT);
SecDescr := ClassSecDescr.Descriptor;
SecDescr.Edit;
// Deny any operations with express reports to the USER user
Type := AceType.AccessDenied;
Sid := MB.Security.ResolveName("USER").Sid;
SecDescr.Acl.AddAce(Type, Sid, MetabaseObjectPredefinedRights.All);
SecDescr.Apply(False);
// 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;
SecDescrs: IMetabaseClassesSecurityDescriptors;
ClassSecDescr: IMetabaseClassSecurityDescriptor;
MS: IMetabaseSecurity;
SecDescr: ISecurityDescriptor;
Lic: Object;
Type: AceType;
Sid: MetabaseSid;
Begin
MB := Params.Metabase;
// Check out license to work with security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.lftAdm);
MS := MB.Security;
// Get security parameters of the Express Report object type
SecDescrs := MS.MetabaseClassesSecurityDescriptors;
ClassSecDescr := SecDescrs.ItemByClassId[MetabaseObjectClass.KE_CLASS_EXPRESSREPORT];
SecDescr := ClassSecDescr.Descriptor;
SecDescr.Edit();
// Deny any operations with express reports to the USER user
Type := AceType.aceAccessDenied;
Sid := MB.Security.ResolveName("USER").Sid;
SecDescr.Acl.AddAce(Type, Sid, 1);
SecDescr.Apply(False);
// Save changes
MS.Apply();
// Check in license
Lic := Null;
End Sub;
After executing the example the USER user will be forbidden to do any operations with express reports.
See also: