Monday 1 August 2011

Programmatically get Roles for current user in SharePoint 2010


To display Roles for current user see the example below -

SPSite currentSite = SPContext.Current.Site;

SPWeb currentWeb = currentSite.OpenWeb();

SPRoleDefinitionBindingCollection roles = currentWeb.AllRolesForCurrentUser;

foreach(SPRole role in roles)

{

   Response.Write(role.Name);

}

Ads by Google

No comments:

Post a Comment