IABACRootPolicyObject.Load

Syntax

Load(Reader: IXmlDomElement);

Load(Prognoz.Platform.Interop.MsXml2.IXMLDOMElement);

Description

The Load method loads attribute-based access control structure from XML file.

Comments

It is used to create the attribute-based access control that is not connected with general security policy. Loaded structure of attribute-based access control from XML file is not loaded in the security manager interface.

To save attribute-based access control structure to XML file, use the IABACRootPolicyObject.Save method.

Example

To execute the example make sure that XML file contains a structure of attribute-based access control elements: policies set, policies, rules.

Add links to the ABAC, Metabase, Ui, Xml (for Fore.NET example use MsXml2), ForeSystem (for the Fore.NET example) system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MS: IMetabaseSecurity;
    PolicyObject: IABACRootPolicyObject;
    XMLDoc: IXMLDOMDocument;
    XMLElem: IXMLDOMElement;
    XMLName, XMLElemName: String;
    Lic: Object;
Begin
    MB:= MetabaseClass.Active;
    
// Get license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    MS:= MB.Security;
    
// Download attribute-based access control structure from XML file
    XMLName:= "C:\temp\ABAC.xml";
    XMLElemName:= 
"ABAC";
    XMLDoc := 
New DOMDocument60.Create;
    
If XMLDoc.load(XMLName) Then
        XMLElem := XMLDoc.selectSingleNode(XMLElemName) 
As IXmlDomElement;
        
If XMLElem <> Null Then
            MS.Policy.ABACRules.Load(XMLElem);
            MS.Apply;
        
Else
            WinApplication.ErrorBox(
"The specified element is not found");
        
End If;
    
Else
        WinApplication.ErrorBox(
"Error on XML downloading");
    
End If;
    
// Check in license
    Lic := Null;
End Sub UserProc;

Imports Prognoz.Platform.Interop.ABAC;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.MsXml2;
Imports Prognoz.Platform.Interop.Ui;
Imports Prognoz.Platform.Interop.ForeSystem;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    MS: IMetabaseSecurity;
    PolicyObject: IABACRootPolicyObject;
    XMLDoc: FreeThreadedDOMDocument60;
    XMLElem: IXMLDOMElement;
    XMLName, XMLElemName: String;
    Lic: Object;
    WinApp: WinApplicationClassClass = 
New WinApplicationClassClass();
Begin
    MB:= Params.Metabase;
    
// Get license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.lftAdm);
    MS:= MB.Security;
    
// Download attribute-based access control structure from XML file
    XMLName:= "C:\temp\ABAC.xml";
    XMLElemName:= 
"ABAC";
    XMLDoc := 
New DOMDocument60.Create();
    
If XMLDoc.load(XMLName) Then
        XMLElem := XMLDoc.selectSingleNode(XMLElemName) 
As IXmlDomElement;
        
If XMLElem <> Null Then
            MS.Policy.ABACRules.Load(XMLElem);
            MS.Apply();
        
Else
            WinApp.ErrorBox(
"The specified element is not found"Null);
        
End If;
    
Else
        WinApp.ErrorBox(
"Error on loading XML"Null);
    
End If;
    
// Check in license
    Lic := Null;
End Sub;

After executing the example the attribute-based access control structure will be downloaded from XML file. If any errors occur on downloading XML file or the ABAC element will not be found in the file, the corresponding message is displayed.

See also:

IABACRootPolicyObject