Home All Groups Group Topic Archive Search About

programatically how to set the steps involved in enabling the ASP.

Author
30 Sep 2005 9:28 AM
Dur

Hi all,
I am facing one problem while  generating the entries in the EventLog in
ASP.NET.
That error is " registry access is  not allowed". So i found some code in
the google regarding registry access. So i followed it and finally  working
well.

I set those permissions manually(Not programmatically). But i want it
programatically. The steps are given below.

Can you help me how to set the below steps programmatically.

1. Launch RegEdit
2. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\
    CurrentControlSet\Services\EventLog\
3. From the menu, select Edit->Permissions
4. Click the Add button and write ASPNET.  (if ASP.NET is running under a
different user id, use that id instead)
5. Click OK.
6. Select the newly added user from the list (ASP.NET Machine User by
default).
7. Click on Full Control in the Allow column.
8. Click OK.

It is usually a good idea at this point to restart IIS with the IISReset
command (Start | Run | IISReset).

regards
Srihari k

Author
30 Sep 2005 1:16 PM
Kevin Spencer
You're barking up the wrong tree, Srihari. You can't modify the Registry if
you don't have permission to use the Registry.

You certainly can modify the Registry programmatically, using the
Microsoft.Win32 .Registry and Microsoft.Win32.RegistryKey classes, but
again, you wouldn't be able to if you don't have permission.

You CAN use the WindowsIdentity class (and some unmanaged code) to
impersonate a user account that has whatever permissions your app needs, as
long as you know the domain, user name, and password for that account. See:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecurityprincipalwindowsidentityclassimpersonatetopic.asp

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Big things are made up of
lots of little things.

Show quoteHide quote
"Dur" <D**@discussions.microsoft.com> wrote in message
news:0F4EDA73-F71A-445F-909C-7F682D835BDF@microsoft.com...
> Hi all,
> I am facing one problem while  generating the entries in the EventLog in
> ASP.NET.
> That error is " registry access is  not allowed". So i found some code in
> the google regarding registry access. So i followed it and finally
> working
> well.
>
> I set those permissions manually(Not programmatically). But i want it
> programatically. The steps are given below.
>
> Can you help me how to set the below steps programmatically.
>
> 1. Launch RegEdit
> 2. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\
>    CurrentControlSet\Services\EventLog\
> 3. From the menu, select Edit->Permissions
> 4. Click the Add button and write ASPNET.  (if ASP.NET is running under a
> different user id, use that id instead)
> 5. Click OK.
> 6. Select the newly added user from the list (ASP.NET Machine User by
> default).
> 7. Click on Full Control in the Allow column.
> 8. Click OK.
>
> It is usually a good idea at this point to restart IIS with the IISReset
> command (Start | Run | IISReset).
>
> regards
> Srihari k
>
>
>

Bookmark and Share