HTTP 500 Internal Server Error

Symptoms

Users receive an error 'HTTP 500 Internal Server Error' while trying to
browse to a SharePoint site using Claims-based authentication. We see the
following error message under the event viewer on the SharePoint server

Log Name : Application
Source                : Microsoft-SharePoint Products-SharePoint Foundation
Date                : <Date and Time>
Event ID : 8305
Task Category     : Claims Authentication
Level : Error
Keywords:     
User :  domain\username
Computer : <servername>
Description         : An exception occurred when trying to establish endpoint for context: An error occurred loading a configuration file: Either a required impersonation level was not provided, or the provided impersonation level is
invalid.
 (C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Config\machine.config).
Event Xml:
<Event xmlns="https://schemas.microsoft.com/win/2004/08/events/event">
 <System>
    <Provider Name="Microsoft-SharePoint
Products-SharePoint Foundation" Guid="{6fb7e0cd-52e7-47dd-997a-241563931fc2}" />
    <EventID>8305</EventID>
 
<Version>14</Version>
    <Level>2</Level>
   
<Task>47</Task>
    <Opcode>0</Opcode>
   
<Keywords>0x4000000000000000</Keywords>
    <TimeCreated SystemTime="Date and Time7Z" />
   
<EventRecordID>11820</EventRecordID>
    <Correlation ActivityID="{1160D9F3-DFB6-414A-A765-58C78EB5170E}" />
    <Execution ProcessID="5948" ThreadID="4908" />
   
<Channel>Application</Channel>
   
<Computer>ServerName</Computer>
    <Security UserID="S-1-5-21-448539723-1767777339-1801674531-1648" />
 
</System>
  <EventData>
    <Data Name="string0">An error occurred loading a configuration file: Either a required impersonation level was not provided, or the provided impersonation level is invalid.
 (C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Config\machine.config)</Data>
 
</EventData>
</Event>

We also noted that if we direct the
requests to another server in the farm, we are able to access the
site.

 

Cause

Application pool account was missing the "Impersonate a client after authentication" user right

 

 

Resolution

1. Go to Start - Administrative tools - Local Security
Policy - Local Policies - User Right Assignments - Impersonate a client after
authentication properties
2. Add the Application Pool account for the site
which is not working
3. Reboot the server, so the changes can take effect
4. Browse the site and it should work fine

 

 

More Information

Get the following error message under the SharePoint ULS LOGS

<Date and Time> w3wp.exe (0x173C) 0x14AC SharePoint Foundation
Claims Authentication fsq6 High Get trust client failed with exception:
System.Configuration.ConfigurationErrorsException: An error occurred loading a
configuration file: Either a required impersonation level was not provided, or
the provided impersonation level is invalid.
(C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Config\machine.config) --->
System.IO.IOException: Either a required impersonation level was not provided,
or the provided impersonation level is invalid. at
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32
rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions
options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at
System.IO.FileStream..ctor(Strin...

<Date and Time> w3wp.exe 
(0x173C) 0x14AC SharePoint Foundation Claims Authentication fsq6 High ...g path,
FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions
options, String msgPath, Boolean bFromProxy) at
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share) at
System.Configuration.Internal.InternalConfigHost.StaticOpenStreamForRead(String
streamName) at
System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.OpenStreamForRead(String
streamName, Boolean assertPermissions) at
System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.OpenStreamForRead(String
streamName) at
System.Configuration.ClientConfigurationHost.OpenStreamForRead(String
streamName) at
System.Configuration.UpdateConfigHost.OpenStreamForRead(Stri...

<Date
and Time> w3wp.exe (0x173C) 0x14AC SharePoint Foundation Claims
Authentication fsq6 High ...ng streamName) at
System.Configuration.BaseConfigurationRecord.FindSection(String[] keys,
SectionXmlInfo sectionXmlInfo, Int32& lineNumber) at
System.Configuration.BaseConfigurationRecord.GetSectionXmlReader(String[] keys,
SectionInput input) --- End of inner exception stack trace --- at
System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys,
SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord,
SectionRecord sectionRecord, Object parentResult) at
System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord
factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg,
Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String...

 <Date
and Time> w3wp.exe (0x173C) 0x14AC SharePoint Foundation Claims
Authentication fsq6 High ... configKey, Boolean getLkg, Boolean checkPermission,
Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object&
resultRuntimeObject) at
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject,
Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at
System.Configuration.ConfigurationSectionCollection.Get(String name) at
System.ServiceModel.Configuration.ServiceModelSectionGroup.get_Client() at
Microsoft.SharePoint.Administration.Claims.SPSecurityTokenServiceApplication.get_Binding()
at Microsoft.SharePoint.SPSecurityContext.GetTrustChannel() at
Microsoft.SharePoint.SPSecurityContext.SecurityTokenForContext(Uri context,
Boolean bearerToken, Securit...

<Date and Time> w3wp.exe (0x173C)
0x14AC SharePoint Foundation Claims Authentication fsq6 High ...yToken
onBehalfOf, SecurityToken actAs, SecurityToken delegateTo)

**** Also creating a web application using Classic auth
modeshows the following error:

An unexpected error has occurred .

Here is the event log entry:

Log Name: Application
Source : ASP.NET 2.0.50727.0
Date: <Date and
Time>
Event ID: 1309
Task Category: Web Event
Level:
Warning
Keywords: Classic
User: N/A
Computer:
COMPUTER.DOMAIN.NET
Description:
Event code: 3005
Event message: An
unhandled exception has occurred.
Event time: <Date and Time>
Event
time (UTC): <Date and Time>
Event ID: 18355ddcec9343279e3e37f780c0a656

Event sequence: 25
Event occurrence: 2
Event detail code: 0

Application information:
Application domain:
/LM/W3SVC/2034998540/ROOT-1-129551416006053706
Trust level: WSS_Minimal

Application Virtual Path: /
Application Path: C:\inetpub\wwwroot\path

Machine name: TESMPWWB
Process information:
Process ID: 4144

Process name: w3wp.exe
Account name: DOMAIN\APPPOOLACCOUNT
Exception
information:
Exception type: COMException
Exception message: The handle
is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))
Request
information:
Request URL: https://websitename.net/favicon.ico
Request
path: /favicon.ico
User host address: <IP Address>
User:
Is
authenticated: False
Authentication Type:
Thread account name:
DOMAIN\APPPOOLACCOUNT
Thread information:
Thread ID: 12
Thread
account name: DOMAIN\APPPOOLACCOUNT
Is impersonating: False
Stack trace: