Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / December 2005

Tip: Looking for answers? Try searching our database.

Tried everything - "Requested registry access is not allowed"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LP - 05 Nov 2004 10:52 GMT
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(String 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
Scott M. - 05 Nov 2004 16:00 GMT
Just for kicks, change the:

HKLM\System\CurrentControlSet\Services\Eventlog

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

> Hi,
>
[quoted text clipped - 44 lines]
> Thanks
> LP
LP - 08 Nov 2004 07:35 GMT
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\EventLog". 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

> Just for kicks, change the:
>
[quoted text clipped - 50 lines]
> > Thanks
> > LP
Dan Rogers - 04 Dec 2004 00:56 GMT
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: <07DB319A-1A60-41FF-A1F7-419C192F6B1B@microsoft.com>
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(String 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
Annadurai.S - 28 Dec 2005 12:31 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.