468,535 Members | 1,528 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,535 developers. It's quick & easy.

Tried everything - "Requested registry access is not allowed"

LP
Hi,

My webservice is currently deployed on WIndows 2000 server and runs pretty
fine. I am trying to run my webservice on a Windows 2003 server. My
webservice tries to write to a eventlog. The code is as follows:

System.Diagnostics.EventLog Log = new System.Diagnostics.EventLog(
EventLogName );
Log.Source = EventLogName;
Log.WriteEntry( "PCHistory Service Application started up successfully.",
System.Diagnostics.EventLogEntryType.Information );

I am getting the following error.

System.Security.SecurityException: Requested registry access is not allowed.
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at System.Diagnostics.EventLog.CreateEventSource(Stri ng source, String
logName, String machineName, Boolean useMutex)
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
type, Int32 eventID, Int16 category)
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
type, Int32 eventID)
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
type)
at PCHistory.PCHistoryService.Log(String Message, EventLogEntryType type)
at PCHistory.PCHistoryService.LogInfo(String Message, Object[] args)
at PCHistory.PCHistoryService..ctor()

I tried the following:
1. Giving full rights to ASPNET account on
HKLM\System\CurrentControlSet\Services\Eventlog
2.Giving SetValue and CreateSubkey rights to ASPNET account on the same.
3.Changing machine .config process model attribute of USerName to SYSTEM.
4. Creating the Source manually in the registry.

Nothing worked.

If u have solution please reply ASAP.

Thanks
LP
Nov 21 '05 #1
4 45617
Just for kicks, change the:

HKLM\System\CurrentControlSet\Services\Eventlog

key so that "Everyone" has full access and try it then.

"LP" <LP@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
Hi,

My webservice is currently deployed on WIndows 2000 server and runs pretty
fine. I am trying to run my webservice on a Windows 2003 server. My
webservice tries to write to a eventlog. The code is as follows:

System.Diagnostics.EventLog Log = new System.Diagnostics.EventLog(
EventLogName );
Log.Source = EventLogName;
Log.WriteEntry( "PCHistory Service Application started up successfully.",
System.Diagnostics.EventLogEntryType.Information );

I am getting the following error.

System.Security.SecurityException: Requested registry access is not
allowed.
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at System.Diagnostics.EventLog.CreateEventSource(Stri ng source, String
logName, String machineName, Boolean useMutex)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType
type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType
type, Int32 eventID, Int16 category)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType
type, Int32 eventID)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType
type)
at PCHistory.PCHistoryService.Log(String Message, EventLogEntryType type)
at PCHistory.PCHistoryService.LogInfo(String Message, Object[] args)
at PCHistory.PCHistoryService..ctor()

I tried the following:
1. Giving full rights to ASPNET account on
HKLM\System\CurrentControlSet\Services\Eventlog
2.Giving SetValue and CreateSubkey rights to ASPNET account on the same.
3.Changing machine .config process model attribute of USerName to SYSTEM.
4. Creating the Source manually in the registry.

Nothing worked.

If u have solution please reply ASAP.

Thanks
LP

Nov 21 '05 #2
LP
Hi,

I figured out the problem. It was improper access rights (in the event log)
to the account the webservice was running under. When I started looking into
the IIS, I found that the Default application pool ran under the identity of
"Network Service" which is the least priveleged account. Hence it has minimal
access i.e security associated to it is high. This did not allow creating a
new event log and writing into it. I have several options which we can decide
to utilise:

1.Change IIS Isolation Mode Setting:
Right click on "WebSites" under IIS 6.0. Then Click to open the "Service"
tab. Check the chekcbox labelled "Run WWW service in IIS 5.0 isolation
mode.". Click OK and then restart IIS. This will allow your app to run in IIS
5.0 mode.
2. Change IIS Application Pool Setting:
Click on Application Pools under IIS. Right click on the "DefaultAppPool".
Go to the "Identity" tab, and change the Predefined value to "LocalSystem".
CLick Yes on the warning and Click OK.
3. Change Registry setting:
Go to "HKEY_LOCAL_MACHINE\System\CurrentCOntrolSet\Event Log". RIght click
on "eventLog" and choose "permissions". Click on the "Advanced" tab below.
This will open the "Advanced Security settings for event log" dialog box.
Click on the "Add" button in the "Permissions" tab. This will open the
"Select USer or Group" dialog box. Click "Advanced" button and find the
"NETWORK SERVICE" account. Select this account and click on OK. Confirm the
account by clicking OK on the "Select User or Group" dialog box. This will
open the "Permission entry for event log" dialog box. Check on the "Set
Value" and "Create SUbkey" items and click on OK. Now confirm on all the
underlying dialog boxes by clicking on OK.
I feel the last one is the best solution.

THanks
LP
"Scott M." wrote:
Just for kicks, change the:

HKLM\System\CurrentControlSet\Services\Eventlog

key so that "Everyone" has full access and try it then.

"LP" <LP@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
Hi,

My webservice is currently deployed on WIndows 2000 server and runs pretty
fine. I am trying to run my webservice on a Windows 2003 server. My
webservice tries to write to a eventlog. The code is as follows:

System.Diagnostics.EventLog Log = new System.Diagnostics.EventLog(
EventLogName );
Log.Source = EventLogName;
Log.WriteEntry( "PCHistory Service Application started up successfully.",
System.Diagnostics.EventLogEntryType.Information );

I am getting the following error.

System.Security.SecurityException: Requested registry access is not
allowed.
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at System.Diagnostics.EventLog.CreateEventSource(Stri ng source, String
logName, String machineName, Boolean useMutex)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType
type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType
type, Int32 eventID, Int16 category)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType
type, Int32 eventID)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType
type)
at PCHistory.PCHistoryService.Log(String Message, EventLogEntryType type)
at PCHistory.PCHistoryService.LogInfo(String Message, Object[] args)
at PCHistory.PCHistoryService..ctor()

I tried the following:
1. Giving full rights to ASPNET account on
HKLM\System\CurrentControlSet\Services\Eventlog
2.Giving SetValue and CreateSubkey rights to ASPNET account on the same.
3.Changing machine .config process model attribute of USerName to SYSTEM.
4. Creating the Source manually in the registry.

Nothing worked.

If u have solution please reply ASAP.

Thanks
LP


Nov 21 '05 #3
A better way to do this is to put the event log writing code in a fully
trusted assembly, and attribute it to With
AllowPartiallyTrustedCallersAttribute.

--------------------
Thread-Topic: Tried everything - "Requested registry access is not allowed"
thread-index: AcTDHRlsTLtD0O4QQiy1g2fAjbWA5g==
X-WBNR-Posting-Host: 164.164.12.225
From: "=?Utf-8?B?TFA=?=" <LP@discussions.microsoft.com>
Subject: Tried everything - "Requested registry access is not allowed"
Date: Fri, 5 Nov 2004 01:52:02 -0800
Lines: 43
Message-ID: <07**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7257
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

Hi,

My webservice is currently deployed on WIndows 2000 server and runs pretty
fine. I am trying to run my webservice on a Windows 2003 server. My
webservice tries to write to a eventlog. The code is as follows:

System.Diagnostics.EventLog Log = new System.Diagnostics.EventLog(
EventLogName );
Log.Source = EventLogName;
Log.WriteEntry( "PCHistory Service Application started up successfully.",
System.Diagnostics.EventLogEntryType.Information );

I am getting the following error.

System.Security.SecurityException: Requested registry access is not allowed.
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at System.Diagnostics.EventLog.CreateEventSource(Stri ng source, String
logName, String machineName, Boolean useMutex)
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
type, Int32 eventID, Int16 category)
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
type, Int32 eventID)
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType
type)
at PCHistory.PCHistoryService.Log(String Message, EventLogEntryType type)
at PCHistory.PCHistoryService.LogInfo(String Message, Object[] args)
at PCHistory.PCHistoryService..ctor()

I tried the following:
1. Giving full rights to ASPNET account on
HKLM\System\CurrentControlSet\Services\Eventlog
2.Giving SetValue and CreateSubkey rights to ASPNET account on the same.
3.Changing machine .config process model attribute of USerName to SYSTEM.
4. Creating the Source manually in the registry.

Nothing worked.

If u have solution please reply ASAP.

Thanks
LP

Nov 23 '05 #4

Hi,
try this way you may resolve that error

just goto control panel->Administartive tools->eventLog
delete all the application/systems events

and if you have used in your application like
Eventlog(ServiceConfig)

in business logic

BeginTransaction()
{
}
rollback transaction()
{

}
committransction()
{

}
endtransaction()
{
}
you should have to comment like

BeginTransaction()
{

/* some set of codes... */
}
rollback transaction()
{

/* some set of codes... */

}
committransction()
{
/* some set of codes... */

}
endtransaction()
{
/* some set of codes... */

}

if your os is XP means it works fine without commenting now you are
using windows 2000 server so try my way

Thanks
Annadurai.S

--
Annadurai.S
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1204708.html

Dec 29 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by burut | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.