Hi David,
We do not have a method to check permissions for a role but we do have a method to check permissions for a user. Following the example below, you could create a fake user on execution, assign it to a role, check the permissions, then delete the user.
private bool CheckDocumentPermissions()
{
// Create an instance of the Tree provider
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
// Get default culture code
string culture = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCultureCode");
// Get the API Example document
TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example", culture);
if (node != null)
{
// Get the user
UserInfo user = UserInfoProvider.GetUserInfo("Andy");
if (user != null)
{
// Check permissions and perform an action according to the result
if (TreeSecurityProvider.IsAuthorizedPerNode(node, NodePermissionsEnum.ModifyPermissions, user) == AuthorizationResultEnum.Allowed)
{
apiCheckDocumentPermissions.InfoMessage = "User 'Andy' is allowed to modify permissions for document 'API Example'.";
}
else
{
apiCheckDocumentPermissions.InfoMessage = "User 'Andy' is not allowed to modify permissions for document 'API Example'.";
}
return true;
}
}
return false;
}
This example can be found under
Site Manager > Support > API Examples.
Please let me know if this approach would work for you.
Thanks,
Sandro