DeviceName: String;
DeviceName: System.String;
The DeviceName property returns the device name.
The property is used if limit mode is set for the printers used for printing.
To execute the example add links to the Metabase, ForeSystem (for Fore.NET example) system assemblies. Add a link to the System.Windows.Forms NET-assembly for Fore.NET example.
Sub UserProc;
Var
MB: IMetabase;
MS: IMetabaseSecurity;
MP: IMetabasePolicy;
DP: IMetabaseDevicePolicy;
DevDess: IMetabaseDeviceDescriptors;
Users: IMetabaseUsers;
User: IMetabaseUser;
Printers: IMetabaseDeviceDescriptors;
DevDes: IMetabaseDeviceDescriptor;
Category: ISecurityCategory;
Desc: ISecurityDescriptor;
Lic: Object;
Begin
MB := MetabaseClass.Active;
Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
MS := MB.Security;
MP := MS.Policy;
DP := MP.PrintersPolicy;
DevDess := DP.Enumerate;
Users := MS.Users;
User := Users.Administrator;
Printers := User.Printers;
Try
DevDess.Add("printserver1\Microsoft Office Document Image Writer");
DevDes := DevDess.Add("printserver2\snagit 8");
Except On e: Exception Do
WinApplication.InformationBox(e.Message);
End Try;
Desc := DevDes.SecurityDescriptor;
Desc.Edit;
Category := MP.MandatoryAccess.Category(0);
Desc.AccessToken.ClassificationLabel(Category) := Category.Level(1);
Desc.Apply(False);
Printers.Add(DevDes.DeviceName);
MS.Apply;
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;
MP: IMetabasePolicy;
DP: IMetabaseDevicePolicy;
DevDess: IMetabaseDeviceDescriptors;
Users: IMetabaseUsers;
User: IMetabaseUser;
Printers: IMetabaseDeviceDescriptors;
DevDes: IMetabaseDeviceDescriptor;
Category: ISecurityCategory;
Desc: ISecurityDescriptor;
Lic: Object;
Begin
MB := Params.Metabase;
Lic := MB.RequestLicense(UiLicenseFeatureType.lftAdm);
MS := MB.Security;
MP := Ms.Policy;
DP := MP.PrintersPolicy;
DevDess := DP.Enumerate();
Users := MS.Users;
User := Users.Administrator;
Printers := User.Printers;
Try
DevDess.Add("printserver1\Microsoft Office Document Image Writer");
DevDes := DevDess.Add("printserver2\snagit 8");
Except On e: System.Exception Do
System.Windows.Forms.MessageBox.Show(e.Message);
End Try;
Desc := DevDes.SecurityDescriptor;
Desc.Edit();
Category := MP.MandatoryAccess.Category[0];
Desc.AccessToken.ClassificationLabel[Category] := Category.Level[1];
Desc.Apply(False);
Printers.Add(DevDes.DeviceName);
MS.Apply();
Lic := Null;
End Sub;
After executing the example, two printers are added to the security policy, one of them is added to the list of administrator printers available for printing with security level on.
See also: