RoleAssignments.GetAssignmentByPrincipal(siteGroup) Error

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,

I am using following code snippet
foreach (SPGroup group in itemWeb.Groups)
{
siteGroup = group;
SPSecurity.CodeToRunElevated
elevatedCodeForAssignment = new
SPSecurity.CodeToRunElevated(GetRoleAssignments);

SPSecurity.RunWithElevatedPrivileges(elevatedCodeForAssignment);
}

void GetRoleAssignments()
{
SPRoleAssignment assignment =
currentWeb.RoleAssignments.GetAssignmentByPrincipal(siteGroup);
}


This code works correctly when Site Collection admin is logged in,but
crashes with "Access Denied" whenever visitor is logged in.

Anyone having any idea how to get this code executed.
I am already running the code with elevated permissions.

Regards,
Amit
.