Hi
I have a requirement to limit access to View of Report on security role. So I'm working on a plugin on retrievemultiple message. Basically the plugin check user's security role then the view should not be visible. I registered the plugin on retrievemultiple message on savedquery.
This is the code.
FetchExpression fe = context.InputParameters["Query"] as FetchExpression;
var fetchToQueryExpressionRequest = new FetchXmlToQueryExpressionRequest
{
FetchXml = fe.Query
};
var fetchToQueryExpressionResponse = (FetchXmlToQueryExpressionResponse)service.Execute(fetchToQueryExpressionRequest);
QueryExpression objQueryExp = fetchToQueryExpressionResponse.Query;
if (objQueryExp.EntityName == "savedquery")
{
trace.Trace("qe.EntityName:");
trace.Trace(objQueryExp.EntityName.ToString());
if (objQueryExp.Criteria != null)
{
trace.Trace("qe.Criteria:");
trace.Trace(objQueryExp.Criteria.ToString());
if (objQueryExp.Criteria.Conditions != null)
{
trace.Trace("qe.Criteria.Conditions:");
trace.Trace(objQueryExp.Criteria.Conditions.ToString());
string roleName = "System Administrator";
bool userRoleFound = VerifyIfUserHasRole(roleName, context.UserId, service);
if (userRoleFound)
{
trace.Trace("userRoleFound:");
trace.Trace(userRoleFound.ToString());
ConditionExpression queryCondition = new ConditionExpression("name", ConditionOperator.Equal, "Admin Reports");
trace.Trace("userRoleFound:");
trace.Trace(queryCondition.ToString());
objQueryExp.Criteria.Conditions.Add(queryCondition);
}
}
}
}
It is not getting triggered on the View
This is the Plugin Registeration.
Thanks