SharePoint – 403 for only some users, some pages!

I have been getting the following error for only some users, and on some pages that has a web part that I created that checks for their username information.

403 Forbidden – The website declined to show this page, most likely cause, this website requires you to log in

Yes, I tried logging out and logging back in.  I have tried everything….

Here is my code:


        Microsoft.SharePoint.SPSite site = Microsoft.SharePoint.SPContext.Current.Site;

        Microsoft.SharePoint.SPServiceContext context = Microsoft.SharePoint.SPServiceContext.GetContext(site);

        // Uses the profile manager that was set up in Central Admin
        Microsoft.Office.Server.UserProfiles.UserProfileManager profileManager = new Microsoft.Office.Server.UserProfiles.UserProfileManager(context);

        if (impersonate.Length == 0)
            // Used this, but there is no difference: staffMember = SPContext.Current.Web.CurrentUser.LoginName.ToString();
            // Used this, but there is no difference: staffMember = System.Web.HttpContext.Current.Request.ServerVariables["AUTH_USER"];
            staffMember = HttpContext.Current.User.Identity.Name;
            staffMember = impersonate;

Regardless of the different combinations I tried, I got this error only for some users, and only on some of the pages. So far my trend has only been the web part I created with this code. If I bypass that code (and I have a query string that allows me to impersonate a user) it will work just fine

Here is the error:


So after about 8 hours of troubleshooting, I finally figured out it would work just fine if I added that user that was having issues to the Administrators Group on the local SharePoint server after performing an IISReset.

So, after playing around a bit more I added “NT Authority\Network” (a local account) as a local admin instead of the user that was having a problem, performed an IISReset, and it worked as it should now for that user and all of the affected users.


I am waiting to hear back from Microsoft to see if this is a recommended solution to the issue, or if there is a better practice solution that I should be following.

I will keep this post updated.

Categories: SharePoint or Custom Development | 4 Comments

Post navigation

4 thoughts on “SharePoint – 403 for only some users, some pages!

  1. RIdhvi

    Hi Bill
    I too got the same problem while deploying custom pages to a sharepoint site, by going through your way we solved the problem, but by doing so your system is open for all Active directory users which is a security concern…so practically it’s not the solution..
    Do you have any other solution for this….?

  2. anon

    Our solution to a similar problem (403 error for some users) was to give “Everyone” access to the “List folder contents” permission on the virtual directory. Hope this helps someone.

  3. Chewy

    Has this solution been fixed in a CU update?

  4. Kyle

    Hi Bill, I am wondering if you ever got this working without adding the network as an administrator to the local server. I am having a similar problem with a custom module that was installed on a SP 2010 site. Once I used your solution everything was back to normal.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

%d bloggers like this: