Your problem on Windows authentication mode essentially similar with these problems:
System.Security.SecurityException when writing to Event Log
System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.
The exception means that your web app tried to write on event log using a value given to "source" which has not been registered due to insufficent privilege on corresponding account.
When using Windows authentication mode to perform event log tasks, you need to give read permission on NETWORK SERVICE
account on eventlog\Security
key. Below are these steps to do:
- Open Regedit (Registry Editor).
- Go to
HKLM\SYSTEM\CurrentControlSet\services\eventlog\Security
- Right click the branch, select "Permissions".
- Click "Add", find RDN named
NETWORK SERVICE
or type it directly, then add the account.
- Under "Permissions for Network Service", check "Read" or "Full Control" to give the read permission, then apply the change.
- Restart your application pool on IIS host.
If it still not enough, do actions below:
Open IIS Manager. Check the Identity column on Application Pools
section, it should given LocalSystem
or NetworkService
.
When you need to change Identity, right click the application pool with Windows authentication, choose Advanced Settings.
Under Process Model, change ApplicationPoolIdentity
to LocalSystem
or NetworkService
, apply your edit and restart the application pool.
NB: NetworkService
identity is more preferred to LocalSystem
due to security vulnerability reasons.
Also you may try setting <trust level="Full" />
in web.config
file, depending on security consideration.
If all solutions above still won't work, set Visual Studio on development machine or deployed app on web server to run as administrator privilege, gaining full access to Windows authentication event log. After all, it depends of your choice to ensure proper security measure was applied.