Defining Protected Pages through Metadata
System administrators can define protected RTA pages by storing metadata in multi-select elements.
Important
Keep in mind that storing RTA
metadata in pages is the last step in the three-step RTA process. In isolation, metadata does
not automatically implement RTA on these pages. This configuration
task only identifies pages requiring protection so that they can be
aggregated into a list. Each page in the list receives RTA
protection.
In this scenario, each page schema in the DSS site has an
<authorization>
element that looks like this:
<authorization type="multiselect" label="Authorization" undefined="" required="false" maxchoices="" pagesize=""
hidden="false"/>
In the Edit tab, this code displays as a multi-select element where system administrators can set the page as protected.
The following code block, once added to [Drive]:\[path-to-site-root-folder]\site\App_Data\xml\Custom\Get_Element_Values.cs, uses the function called GetElementValues to protect pages marked for authentication behind RTA.
Note
In this example, the choice hook applies values defined in the
GetElementValues function to a page element that has an element name
match.
function getElementValues(schemaName, elementName, options, site)
{
if(elementName == "Authorization")
{
var validRoles = [];
var req = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
req.Open("POST", "http://path/to/web/service", false);
req.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.Send("key&value&key=value");
if(req.status == 200)
{
var doc = new ActiveXObject("MSXML2.DomDocument.4.0");
doc.loadXML(req.responseText);
if(doc.documentElement != null)
{
var roleIdNodes = doc.selectNodes("//DesiredValue");
var nodeCount = roleIdNodes.length;
for(var i = 0; i < nodeCount; i++)
{
var role = roleIdNodes.item(i);
validRoles.push(role.text);
}
}
}
return validRoles;
}
}
Related Topics