Tim Huffam

Dotting the I and crossing the T of I.T.

  Home  |   Contact  |   Syndication    |   Login
  153 Posts | 0 Stories | 2747 Comments | 653 Trackbacks

News

Archives

Post Categories

Interesting Blogs/Links

I got this error when I try to create an eventlog source and when I try to write to the new event log (after resorting to manually creating the event log source) with my ASP.NET application.

See the end of this post for the full error message and stack trace.

This seems to be a very commom problem - and not consistent either.  My guess is that it's due to the tightening of security recently, ie XP SP2.  Use of the Network Service account (on win2k3) or AD accounts can help.

To resolve you need to give the ASP.NET user permission to read from the event log registry entries.  And here's how:

  1. Select Start - Run, then enter: regedt32
  2. Navigate/expand to the following key:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Security
  3. Right click on this entry and select Permissions
  4. Add the ASPNET user
  5. Give it Read permission

Bingo! - your app should now work.

HTH

Tim

Full error message:

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Requested registry access is not allowed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[SecurityException: Requested registry access is not allowed.]

Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) +473

System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly) +296

System.Diagnostics.EventLog.SourceExists(String source, String machineName) +79

System.Diagnostics.EventLog.SourceExists(String source) +11

DrKW.Directory.DebugLog.LogEntry(String logMessage, EventLogEntryType type) +16

DrKW.Directory.DebugLog.Error(String logMessage) +18

DrKW.Directory.HttpModule.ConfigSectionHandler.Create(Object parent, Object configContext, XmlNode configNode) in C:\.NETLocalProjects\DrKWDirectory\Directory.HttpModule\Configuration\ConfigSectionHandler.cs:72

System.Web.Configuration.HttpConfigurationRecord.EvaluateRecursive(IConfigurationSectionHandler factory, Object config, String[] keys, Int32 iKey, XmlUtil xml) +333

posted on Wednesday, October 5, 2005 8:46 AM

Feedback

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 10/11/2005 8:11 AM Khuzema
The problem and still there. Incidentally the right click on security does not work in regedt32, so i have given the authority from menu bar.
any further option we can try????
thanks

khuzema

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 10/11/2005 12:06 PM Tim
What OS are you running?

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 10/12/2005 5:49 PM khuzema
Windows Server 2003

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 10/18/2005 5:02 PM Roy
not able to solve this problem. I am using XP.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 10/18/2005 5:03 PM Roy
not able to solve this problem. I am using XP.
my mail id - dipankarroy1209@gmail.com

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 10/21/2005 4:42 AM Robert
It worked fine 4 me!

Thanx Tim

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 10/21/2005 6:31 AM Tim Huffam
For those of you who are still in the poo....

As the error message states, it *is* a security issue.

So before doing anything you need to identify the ASP.NET worker process user.

On Win2k3 ASP.NET uses the user NETWORK SERVICE but on XP & 2k it uses the ASPNET user. You can confirm this by looking in your machine.config (and on 2k3 double check the identity used by the app pool your web app uses). If you're really lost then look in TaskManager - but it can be difficult to identify if there are many wp's.

Once you know the user, try applying the registry change I mentioned in the blog entry above.

If that fails, you can try this (but definately not recommended on anything other than development environments)... either: give the ASP.NET user administrator rights, or, change the user to one that is an administrator.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 10/25/2005 1:42 PM Mike Barlow
I had the same problem as all of you who could not get this solution to work, but it did direct me in the correct direction. I gave read permisions to ASPNET to the Security key, but this did not work. I decided to go one level up to Eventlog and give ASPNET full control. This solved my problem. I do not know if this is the optimal solution, but it worked.

After solving the issue, I decided to try to reproduce the error once again, to see if there was a better way to solve the problem. But when i remove ASPNET from Eventlog, the application continued to run fine.

Good luck

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 11/8/2005 6:30 AM Vijeta
Thanx it worked for me.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 11/15/2005 10:34 AM Aurelio J.Maldonado
For me it has been solved by granting "Full Control" to "IUSR_machinename" user on HKLM\...\EventLog and only "Read permission" also to "IUSR_machinename" user on HKLM\...\EventLog\Security.
When I tried with ASPNET user, it didn't work at all with any permissions.
Thanks, Aurelio.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 12/1/2005 3:17 PM M Hafeez
I am an Admin on my machine so I went to "IUSR_machinename" and made it a member of "Administrators" in addition to "Users" (which it already was) and it worked.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 12/10/2005 11:18 AM Benjy
Awesome. Thanks a lot. I had to give full permissions up a level (EVENT LOG) to the domain user who was used for impersonation and this worked brilliantly.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 1/26/2006 6:05 PM Take That's Gary Barlow
Mike Barlow's solution was what worked for me:

"I had the same problem as all of you who could not get this solution to work, but it did direct me in the correct direction. I gave read permisions to ASPNET to the Security key, but this did not work. I decided to go one level up to Eventlog and give ASPNET full control. This solved my problem. I do not know if this is the optimal solution, but it worked.

After solving the issue, I decided to try to reproduce the error once again, to see if there was a better way to solve the problem. But when i remove ASPNET from Eventlog, the application continued to run fine.

Good luck "

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 1/27/2006 7:15 PM ND
Could someone please explain how to set the permissions in the registry? I am bit confused here.

Thank you.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 1/27/2006 7:30 PM Tim
Go into the Registry Editor (run regedit), find the node you want, right-click on it and select Permissions.

HTH
t

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 1/27/2006 8:01 PM ND
Tim,

Thanks for your response. I did right-click but there was no option for permissions. I am running Win2K, does that make any difference?

Thanks.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 1/29/2006 5:35 AM Pat
I am running on XP Pro and I am having the same issue. I tried giving ASPNet user full access to the Eventlog and also to Eventlog\Security. The problem still remained. So, I then gave fullpermisson to IUSR_machinename but the problem remained.. ANY MORE IDEAS.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 2/8/2006 9:13 AM ramakrishna
It worked fine for me after giving full permissions for eventlog. thanks

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 3/6/2006 5:01 AM andrew
for those on win 2k3 who are still getting the same error even after making a million registry changes - try this: go into IIS, click the permissions of your website/application, click on 'NETWORK SERVICE' user, and give them full control. This is only applicable to dev environments

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 3/21/2006 1:02 PM dave
I am running 2k3 and i gave full control to the NETWORK SERVICE at the EVENTLOG level in the reg and my app worked. I then removed the NETWORK SERVICE account from the EVENTLOG level in the reg and the app still worked. I'm not sure if it will work upon reboot or if I'll have to add the user again, but this definately solved my problem.

Thanks!

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 4/13/2006 6:14 PM Selva
If above mentioned does not work, Try This!
http://blogs.wdevs.com/dpl/archive/2005/09/27/10704.aspx?Pending=true

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 5/2/2006 1:25 PM Bob
I like cats

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 5/5/2006 2:21 AM Kiran
It worked, thanks a lot

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 5/29/2006 6:00 AM amit verma
hi there,

I'm using the win2k and on right click i donot see permission options?

any other Alternative?

Amit

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 5/30/2006 8:24 AM Abhinesh
In Win 2k dont open regedit open regedt32 and select the same Eventlog Folder in HKEY_LocalMAchine window and go security-> Permissions tab in the menu bar and give fullcontrol to the user(Machine)

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 6/16/2006 3:48 PM Chris
Andrew, thanks for the tip. I needed to add NETWORK SERVICE to the permissions of IIS and to the EventLog in the regisitry. As soon as I did that it worked. And as Dave mentioned, I removed both these entries and it still worked. Thanks!

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 7/15/2006 1:08 AM malachite
The steps I did:

"Full Control" to "IUSR_machinename" and "ASPNET" user on HKLM\...\EventLog

and only "Read permission" also to "IUSR_machinename" and "ASPNET" user on HKLM\...\EventLog\Security.

Made "IUSR_machinename" and "ASPNET" as administrators and it worked fine!

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 8/3/2006 6:40 AM Mayan
I'm sorry but all these options still don't work....
I can write to the application eventlog if I use a source that allready exists, but I cannot create a new log or a new source, not even when I tried all the options above.
Does anybody know an other way to create a custom eventlog for my app? Maybe a tool or something. (I use XP pro)

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 8/3/2006 6:57 AM Mayan
Finaly I found a solution at: http://support.microsoft.com/?id=329291

You will have to do this from the commandline.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 10/26/2006 6:15 PM Al
malachite: ASPNET as admin, good security... set Admin rights to Users group... and dont forget the Guest !

# I definatlte deleted... 12/15/2006 12:49 AM Michael
I definatly deleted the ASPUSER account by accidnet.
Hah ^-^' help?

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 12/20/2006 2:15 PM Praveen
Thanks a lot! It worked for me.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 1/12/2007 5:10 AM EVF - MTS - TCOE
Here's what you do.

1.) Set the to permit ASPNET users HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog (I assigned full).
2.) Go to your db and make sure ASPNET user has write access to the db.
3.) Restart SQL then restart IIS.

That worked for me.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 1/30/2007 5:25 PM Ramnaths
Its working by giving full permissions to asp.net user.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 2/20/2007 2:12 PM Pradeep
Add permissions to eventlog in registry. if its still not working, add
<identity impersonate="true" userName= "" password = ""/> in web.config file. provide logon account username and password. This should work and will work !!!!!

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 2/20/2007 2:14 PM ACS_Pradeep
Add permissions to eventlog in registry. if its still not working, add
<identity impersonate="true" userName= "" password = ""/> in web.config file. provide logon account username and password. This should work.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 3/15/2007 10:28 AM devbeans
it worked great for me...just set all permissions mentioned above and this <identity impersonate="true" userName= "" password = ""/> in web.config file. provide logon account username and password.

# just as to look @ microsoft support site 3/24/2007 12:51 AM gustavgmcsd
http://support.microsoft.com/kb/329291


Create an event source under the Application event log in Registry Editor. To do this, follow these steps: 1. Click Start, and then click Run.
2. In the Open text box, type regedit.
3. Locate the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application
4. Right-click the Application subkey, point to New, and then click Key.
5. Type TEST for the key name.
6. Close Registry Editor.

have nothing more to do to solve this problem...

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 4/17/2007 6:14 AM Ganesh B
I TRIED EVERYTHING as below but NO LUCK!!!

SOL:

1. Give the ASPNET user permission to read the Security eventlog registry entry.

Run regedt32
Navigate to the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Security
Right click on this entry and select Permissions
Add the ASPNET user
Give it Read permission

2. Change settings in machine.config file

Run Explorer
Navigate to WINDOWS or WINNT folder
Open Microsoft.NET folder
Open Framework folder
Open v1.1.4322 folder (folder name may be different, depending on what dotnet version is installed)
Open CONFIG folder
Open machine.config file using notepad (make a backup of this file first)
Locate processmodel tag (approx. at line 441)
Locate userName="machine" (approx. at line 452)
Change it to userName="SYSTEM"
Save and close the file
Close Explorer

3. Restart IIS

Run IISReset

I tried this but i am getting this same error while testing my application. For your information I am logging in to my machine as a non-Administrator user. But for Administrator my application works fine even before the above settings.

Please explain me how can i run my application as a non-administrator and to overcome this error while executing some transaction screens which refer the service components.

Thanks,
Ganesh B.



# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 4/19/2007 10:58 PM Tom Perkin
So it strikes me that you are all trying to solve the symptoms rather than the cause. All you need to do is register the Enterprise Library assemblies using installutil.exe. This tool resides in the .NET folder, which is under C:\Windows on XP, or C:\WinNT on Win2k3. Point this at the assemblies and you should be good to go.



# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 9/25/2007 2:07 AM Narmada Patthi
I am in win 2k3 and adding 'NETWORK SERVICE' user to my application and gave full control access..gr8..this worked for me. Thanks for all your inputs..thanks a lot

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 10/15/2007 5:54 PM tronmcp
I found this to be the easiest and fastest fix:

http://support.microsoft.com/kb/842795

# The application attempted to perform an operation not allowed by the security policy. To grant this application the required pe 2/11/2008 7:18 AM ADEEL
i m facing this error The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file

the exception is showing
System.Security.SecurityException: Requested registry access is not allowed.


can u please help me

# System.Security.SecurityException: Requested registry access is not allowed. 2/11/2008 7:19 AM ADEEL
i m facing this problem
System.Security.SecurityException: Requested registry access is not allowed.

can anybody help me out

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 3/18/2008 6:07 AM EVH
Setting full control for the asp_net user and then removing probably works because you need full control to create the event log the first time you write to it, but no longer need full control later because you are simply writing to an existing event log.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 7/5/2008 1:08 AM Rajasekar
Thanks a lot,
I am using wn2k3,I tried those things suggested it dint work but i went one level up and added permissions foe eventlog in regedit added Networkservices and gave full control.it work fine..thanks alot

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 10/31/2008 6:52 PM Nithya
Go to regedit --> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
Eventlog \Security , if ASPNET user is not there means add it and give a read permission.ur issue will be solved now!!!


# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 11/17/2008 9:33 PM David Doumèche
Another way to resolve the issue :
- in IIS console, go to application pool managing your site, and note the identity running it (usually Network Service)
- make sure this identity can read KEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog (rigth-click, authorisations)
- now change the identity of this application pool to Local System, apply, and switch back to Network Service

Credentials will be reloaded and EventLog reacheable

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 4/8/2009 11:24 PM Abhinay
I did the same as 'Take That's Gary Barlow' .. I'm using windows server 2003 as well. and Giving the permissions to Network service to the level 'Event Log' in the registry did the trick... feel so relieved now.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 5/15/2009 7:53 PM Vishal Shah
To resolve you need to give the ASP.NET user permission to read from the event log registry entries. And here's how:

1. Select Start - Run, then enter: regedt32
2. Navigate/expand your parent key
eg. HKEY_Users/.Default
3. Right click on this entry and select Permissions
4. Add the ASPNET user
5. Give it Full permission

Your application will work

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 6/11/2009 12:43 AM parthipan
hi
i'm developed one windows application . i want to set a license for this application at client machine so i decided to develop on asp.net application . my question is i want to read and write remote machine registry key value from my .aspx page.
i developed one aspx page but its worked my machine(local) only after hosting its send a error that is:

System.Security.SecurityException: Requested registry access is not allowed. at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource) at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) at _Default.Button2_Click(Object sender, EventArgs e) in c:\inetpub\vhosts\vertexinfocomm.in\httpdocs\registry.aspx.cs:line 57 The Zone of the assembly that failed was: MyComputer

i'm using vs2005(asp.net and C#) os=xp(sp2)
how do i solve this problem and i need to access remote machine registry key value

any one please help me
thank u


# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 7/22/2009 5:17 AM Henri Koppen
Tim, thx!!!!! I was stuck and this helped me a lot!

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 8/11/2009 9:48 AM Umar
following kb solved my issue.... http://support.microsoft.com/kb/842795

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 5/4/2010 3:04 AM wholesale oil paintings
I have also experienced this situation.I had the same problem as all of you who could not get this solution to work, but it did direct me in the correct direction. I gave read permisions to ASPNET to the Security key, but this did not work. I decided to go one level up to Eventlog and give ASPNET full control. This solved my problem. I do not know if this is the optimal solution, but it worked.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 6/17/2010 1:37 AM Jyoti Sisodiya
Hi ,the same iisue i am faing the same issue , and tried the above suggested solutions but still not getting the solution.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 8/17/2010 7:07 AM Muzafar
It Helped me. I am using windows XP.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 6/2/2011 1:44 PM Lucky
I had the same issue and I gave fullControl on EventLog to myself, means the user which is logged in to the system. It worked for me.

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 7/1/2011 6:26 AM jon
The acctual solution is to set the IIS ASP.Net version to be 4.etc INSTEAD of 2.etc ...

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 7/17/2011 4:16 AM Deepak
i am also getting the same error , please shar a solution..

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 8/24/2011 6:12 AM Kelley
Thank you, thank you, thank you ... if not for this post i would NEVER have fixed my sites issues!

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 8/8/2012 10:05 AM nikhil
access not allowed solve

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 8/8/2012 10:05 AM nikhil
access not allowed solustion

# re: 'System.Security.SecurityException: Requested registry access is not allowed.' when writing to event log 8/8/2012 10:06 AM nikhil
access not allowed solutions

Post A Comment
Title:
Name:
Email:
Comment:
Verification: