Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

SPUser or Permission Collection requiring login authentication

  Asked By: Srikant    Date: Dec 12    Category: Sharepoint    Views: 2497

I am trying to pull a list of members which have access to an area.
This would be similar to the members webpart you can add to a team
site but specifically for an area and not a site. I have implemented
the following code which I believe should function but it throws a
login prompt at execution time preventing the execution of the code
even when I enter the admin credentials. I am executing the code as
our admin user.

PortalContext portalContext = PortalApplication.GetContext(Context);

PageInfo pi = (PageInfo)Context.Items["SPS_PageInfo"];

Guid currAreaGuid = pi.CategoryId;

Area thisArea = AreaManager.GetArea(portalContext, currAreaGuid);

SPWeb currentWeb = SPControl.GetContextSite(Context).OpenWeb

SPPermissionCollection areaPermissions = currentWeb.Permissions;

foreach (SPPermission curPermission in areaPermissions)


strUsers += curPermission.ToString();


// Also have tried...

// SPUserCollection siteUsers = currentWeb.SiteUsers;

// foreach (SPUser curUser in siteUsers)

// {

// strUsers += curUser.Name.ToString();

// }



1 Answer Found

Answer #1    Answered By: Nina Banks     Answered On: Dec 12

add these links and see if it works.

SPWeb web = SPControl.GetContextWeb(Context);
web.Site.CatchAccessDeniedException = false;