Display A SharePoint Users Role Collection

This snippet shows you how to display a particular users set of roles based on the user name parameter.

[csharp]

int Roles = Site.Roles.Count;
for (int iRole = 0; iRole < nRoles; iRole++)
{
        SPRole Role = Site.Roles[iRole];
        UInt32 hexPermMask = (UInt32)Role.PermissionMask;
        lstSiteRoles.Items.Add(
        “Role” + iRole.ToString() + “: ”
        + Role.Name
        + ” [Type:” + Role.Type.ToString()
        + ” PermMask:”
        + hexPermMask.ToString(“X4″) + ” ” + Role.PermissionMask.ToString() + ” ”
        + “]” );
}

[/csharp]

Share

Leave a Reply

Your email address will not be published. Required fields are marked *