Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Security Exception

Reply
Thread Tools

Security Exception

 
 
Tumurbaatar S.
Guest
Posts: n/a
 
      08-18-2005
How to allow the default user account of ASP.NET to access system registry
of WinXP?
My page raises following exception and I believe that happens because my
script
accesses the Event Log of WinXP:

my code:

if (EventLog.SourceExists("MySource"))
EventLog.CreateEventSource("MySource", "MyLog");
using (EventLog ev = new EventLog("MyLog", ".", "MySource"))
{
....
ev.WriteEntry(MyMessage, EventLogEntryType.Error);
....
}

error details:

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) +295
System.Diagnostics.EventLog.SourceExists(String source, String
machineName) +78
System.Diagnostics.EventLog.SourceExists(String source) +11
card.RespFrm.Page_Load(Object sender, EventArgs e) +787
....




 
Reply With Quote
 
 
 
 
Tumurbaatar S.
Guest
Posts: n/a
 
      08-18-2005
I gave Full Control permission to NETWORK SERVICE and ASPNET on
"HK_LM\...\Services\Eventlog" and "..\Eventlog\MyLog" keys. But script
still does not work. Any ideas?


"Tumurbaatar S." <> wrote in message
news:...
> How to allow the default user account of ASP.NET to access system registry
> of WinXP?
> My page raises following exception and I believe that happens because my
> script
> accesses the Event Log of WinXP:
>
> my code:
>
> if (EventLog.SourceExists("MySource"))
> EventLog.CreateEventSource("MySource", "MyLog");
> using (EventLog ev = new EventLog("MyLog", ".", "MySource"))
> {
> ...
> ev.WriteEntry(MyMessage, EventLogEntryType.Error);
> ...
> }
>
> error details:
>
> 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) +295
> System.Diagnostics.EventLog.SourceExists(String source, String
> machineName) +78
> System.Diagnostics.EventLog.SourceExists(String source) +11
> card.RespFrm.Page_Load(Object sender, EventArgs e) +787
> ...
>
>
>
>



 
Reply With Quote
 
 
 
 
Tumurbaatar S.
Guest
Posts: n/a
 
      08-19-2005
I've found some workaround. Setting <processModel> to SYSTEM user
allows ASP.NET app to fully control event log. But it has some security
risks.
Anybody can explain me, please, why ASPNET user with Full Control permission
on "HK_LM\...\Services\Eventlog" key, cannot play with Event Log? What more
rights it should have?

"Tumurbaatar S." <> wrote in message
news:OaSwx%...
>I gave Full Control permission to NETWORK SERVICE and ASPNET on
> "HK_LM\...\Services\Eventlog" and "..\Eventlog\MyLog" keys. But script
> still does not work. Any ideas?
>
>
> "Tumurbaatar S." <> wrote in message
> news:...
>> How to allow the default user account of ASP.NET to access system
>> registry of WinXP?
>> My page raises following exception and I believe that happens because my
>> script
>> accesses the Event Log of WinXP:
>>
>> my code:
>>
>> if (EventLog.SourceExists("MySource"))
>> EventLog.CreateEventSource("MySource", "MyLog");
>> using (EventLog ev = new EventLog("MyLog", ".", "MySource"))
>> {
>> ...
>> ev.WriteEntry(MyMessage, EventLogEntryType.Error);
>> ...
>> }
>>
>> error details:
>>
>> 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) +295
>> System.Diagnostics.EventLog.SourceExists(String source, String
>> machineName) +78
>> System.Diagnostics.EventLog.SourceExists(String source) +11
>> card.RespFrm.Page_Load(Object sender, EventArgs e) +787
>> ...
>>
>>
>>
>>

>
>



 
Reply With Quote
 
Joe Kaplan \(MVP - ADSI\)
Guest
Posts: n/a
 
      08-19-2005
The correct thing to do is to use an adminstrative account to create the
event source and then not do that in your web code. Your code should assume
that the event source already exists and that the application has been
configured correctly by the adminstrator.

If you want to debug a security problem on the registry though, using a tool
like regmon (sysinternals) is extremely helpful.

Joe K.

"Tumurbaatar S." <> wrote in message
news:...
> I've found some workaround. Setting <processModel> to SYSTEM user
> allows ASP.NET app to fully control event log. But it has some security
> risks.
> Anybody can explain me, please, why ASPNET user with Full Control
> permission
> on "HK_LM\...\Services\Eventlog" key, cannot play with Event Log? What
> more
> rights it should have?
>
> "Tumurbaatar S." <> wrote in message
> news:OaSwx%...
>>I gave Full Control permission to NETWORK SERVICE and ASPNET on
>> "HK_LM\...\Services\Eventlog" and "..\Eventlog\MyLog" keys. But script
>> still does not work. Any ideas?
>>
>>
>> "Tumurbaatar S." <> wrote in message
>> news:...
>>> How to allow the default user account of ASP.NET to access system
>>> registry of WinXP?
>>> My page raises following exception and I believe that happens because my
>>> script
>>> accesses the Event Log of WinXP:
>>>
>>> my code:
>>>
>>> if (EventLog.SourceExists("MySource"))
>>> EventLog.CreateEventSource("MySource", "MyLog");
>>> using (EventLog ev = new EventLog("MyLog", ".", "MySource"))
>>> {
>>> ...
>>> ev.WriteEntry(MyMessage, EventLogEntryType.Error);
>>> ...
>>> }
>>>
>>> error details:
>>>
>>> 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) +295
>>> System.Diagnostics.EventLog.SourceExists(String source, String
>>> machineName) +78
>>> System.Diagnostics.EventLog.SourceExists(String source) +11
>>> card.RespFrm.Page_Load(Object sender, EventArgs e) +787
>>> ...
>>>
>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Tumurbaatar S.
Guest
Posts: n/a
 
      08-19-2005
Is there any tool to create an event source? As I understand,
adding a sub-key under "..\Eventlog" key creates a new custom event
log section ("MyLog" in my case). But how to add an event source
("MySource")?


"Joe Kaplan (MVP - ADSI)" <> wrote
in message news:%...
> The correct thing to do is to use an adminstrative account to create the
> event source and then not do that in your web code. Your code should
> assume that the event source already exists and that the application has
> been configured correctly by the adminstrator.
>
> If you want to debug a security problem on the registry though, using a
> tool like regmon (sysinternals) is extremely helpful.
>
> Joe K.
>
> "Tumurbaatar S." <> wrote in message
> news:...
>> I've found some workaround. Setting <processModel> to SYSTEM user
>> allows ASP.NET app to fully control event log. But it has some security
>> risks.
>> Anybody can explain me, please, why ASPNET user with Full Control
>> permission
>> on "HK_LM\...\Services\Eventlog" key, cannot play with Event Log? What
>> more
>> rights it should have?
>>
>> "Tumurbaatar S." <> wrote in message
>> news:OaSwx%...
>>>I gave Full Control permission to NETWORK SERVICE and ASPNET on
>>> "HK_LM\...\Services\Eventlog" and "..\Eventlog\MyLog" keys. But script
>>> still does not work. Any ideas?
>>>
>>>
>>> "Tumurbaatar S." <> wrote in message
>>> news:...
>>>> How to allow the default user account of ASP.NET to access system
>>>> registry of WinXP?
>>>> My page raises following exception and I believe that happens because
>>>> my script
>>>> accesses the Event Log of WinXP:
>>>>
>>>> my code:
>>>>
>>>> if (EventLog.SourceExists("MySource"))
>>>> EventLog.CreateEventSource("MySource", "MyLog");
>>>> using (EventLog ev = new EventLog("MyLog", ".", "MySource"))
>>>> {
>>>> ...
>>>> ev.WriteEntry(MyMessage, EventLogEntryType.Error);
>>>> ...
>>>> }
>>>>
>>>> error details:
>>>>
>>>> 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) +295
>>>> System.Diagnostics.EventLog.SourceExists(String source, String
>>>> machineName) +78
>>>> System.Diagnostics.EventLog.SourceExists(String source) +11
>>>> card.RespFrm.Page_Load(Object sender, EventArgs e) +787
>>>> ...
>>>>
>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Joe Kaplan \(MVP - ADSI\)
Guest
Posts: n/a
 
      08-19-2005
The easiest way is probably to create a small dll assembly project that uses
the EventLogInstaller class and then just run installutil.exe on it during
installation as the adminstrator. There are samples of this in the SDK
documentation on the class.

Alternately, you can do the same CreatEventSource stuff in a small console
application that you run as administrator. It is also possible to modify
the registry directly, although it is more straightforward to use the .NET
classses. Modifying the registry will give you more control though.

HTH,

Joe K.

"Tumurbaatar S." <> wrote in message
news:...
> Is there any tool to create an event source? As I understand,
> adding a sub-key under "..\Eventlog" key creates a new custom event
> log section ("MyLog" in my case). But how to add an event source
> ("MySource")?
>
>
> "Joe Kaplan (MVP - ADSI)" <> wrote
> in message news:%...
>> The correct thing to do is to use an adminstrative account to create the
>> event source and then not do that in your web code. Your code should
>> assume that the event source already exists and that the application has
>> been configured correctly by the adminstrator.
>>
>> If you want to debug a security problem on the registry though, using a
>> tool like regmon (sysinternals) is extremely helpful.
>>
>> Joe K.
>>
>> "Tumurbaatar S." <> wrote in message
>> news:...
>>> I've found some workaround. Setting <processModel> to SYSTEM user
>>> allows ASP.NET app to fully control event log. But it has some security
>>> risks.
>>> Anybody can explain me, please, why ASPNET user with Full Control
>>> permission
>>> on "HK_LM\...\Services\Eventlog" key, cannot play with Event Log? What
>>> more
>>> rights it should have?
>>>
>>> "Tumurbaatar S." <> wrote in message
>>> news:OaSwx%...
>>>>I gave Full Control permission to NETWORK SERVICE and ASPNET on
>>>> "HK_LM\...\Services\Eventlog" and "..\Eventlog\MyLog" keys. But script
>>>> still does not work. Any ideas?
>>>>
>>>>
>>>> "Tumurbaatar S." <> wrote in message
>>>> news:...
>>>>> How to allow the default user account of ASP.NET to access system
>>>>> registry of WinXP?
>>>>> My page raises following exception and I believe that happens because
>>>>> my script
>>>>> accesses the Event Log of WinXP:
>>>>>
>>>>> my code:
>>>>>
>>>>> if (EventLog.SourceExists("MySource"))
>>>>> EventLog.CreateEventSource("MySource", "MyLog");
>>>>> using (EventLog ev = new EventLog("MyLog", ".", "MySource"))
>>>>> {
>>>>> ...
>>>>> ev.WriteEntry(MyMessage, EventLogEntryType.Error);
>>>>> ...
>>>>> }
>>>>>
>>>>> error details:
>>>>>
>>>>> 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) +295
>>>>> System.Diagnostics.EventLog.SourceExists(String source, String
>>>>> machineName) +78
>>>>> System.Diagnostics.EventLog.SourceExists(String source) +11
>>>>> card.RespFrm.Page_Load(Object sender, EventArgs e) +787
>>>>> ...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception of type 'System.Web.HttpUnhandledException' wasthrown.Exception has been thrown by the target of an invocation.System.WebSystem.Exception jobs ASP .Net 1 11-16-2007 05:57 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
IT-Security, Security, e-security COMSOLIT Messmer Computer Support 0 09-05-2003 08:34 AM
Re: bizaar exception that isn't really an exception jeff ASP .Net 3 06-26-2003 01:02 PM
Re: bizaar exception that isn't really an exception jeff ASP .Net 0 06-24-2003 12:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57