Registry - Writing to ..Security / Auth problems

Discussion in 'ASP .Net Security' started by Neal Rogers via .NET 247, Mar 18, 2005.

  1. Hi All

    Using VB.Net
    I have tried unsuccessfully (firstly with a Web App.. and IUSER_MachineName permissions ) to write to the registry.
    So , now I've tried from a windows application, and same result
    ie
    key.SetValue("pwd", sValIn) ' = ERROR: cannot write to the registry key
    ("Run-time exception thrown : System.UnauthorizedAccessException - Cannot write to the registry key.")

    I have set evry possible permission for every listed user on my machine to DenyNothing, and FullControl, and
    in code set RegistryPermissions ..all the code is beneath.

    Still, NO way I can write to registry

    Anybody...???

    TIA
    Neal

    Code....
    'checks to see read functionality
    key = Registry.CurrentUser.OpenSubKey("SOFTWARE\SPLUS\pwd")
    key.GetValue("pwd")

    Dim f As New RegistryPermission(RegistryPermissionAccess.AllAccess, _
    "HKEY_CURRENT_USER\SOFTWARE")
    f.AddPathList(RegistryPermissionAccess.Write, "HKEY_CURRENT_USER\SOFTWARE")
    f.AddPathList(RegistryPermissionAccess.Write, "HKEY_CURRENT_USER\SOFTWARE\SPLUS")
    f.AddPathList(RegistryPermissionAccess.Write, "HKEY_CURRENT_USER\SOFTWARE\SPLUS\pwd")

    f.Assert()

    key.SetValue("pwd", sValIn) 'cannot write to the registry key


    --------------------------------
    From: Neal Rogers

    -----------------------
    Posted by a user from .NET 247 (http://www.dotnet247.com/)

    <Id>AXHq1s34gUao3PPwNtbdMw==</Id>
     
    Neal Rogers via .NET 247, Mar 18, 2005
    #1
    1. Advertising

  2. Neal,

    The overload of OpenSubKey that you are using opens the key for reading
    only. Try using the overload that allows you to specify that you want to
    open the key for writing
    (http://msdn.microsoft.com/library/e...softwin32registrykeyclassopensubkeytopic2.asp).

    Even if the above does resolve the exception you are currently receiving,
    you may run into further problems. The HKEY_CURRENT_USER hive is not
    populated for the runtime execution context users of services (including IIS
    or ASP.NET). Therefore, attempting to use a subkey of HKEY_CURRENT_USER for
    your web application is unlikely to be particularly successful. If the
    value is not meant to vary between users, why not use a subkey of
    HKEY_LOCAL_MACHINE instead? Otherwise, you should probably consider an
    alternate data store.

    HTH,
    Nicole


    "Neal Rogers via .NET 247" <> wrote in message
    news:u84tZ$...
    > Hi All
    >
    > Using VB.Net
    > I have tried unsuccessfully (firstly with a Web App.. and
    > IUSER_MachineName permissions ) to write to the registry.
    > So , now I've tried from a windows application, and same result
    > ie
    > key.SetValue("pwd", sValIn) ' = ERROR: cannot write to the registry key
    > ("Run-time exception thrown : System.UnauthorizedAccessException - Cannot
    > write to the registry key.")
    >
    > I have set evry possible permission for every listed user on my machine to
    > DenyNothing, and FullControl, and
    > in code set RegistryPermissions ..all the code is beneath.
    >
    > Still, NO way I can write to registry
    >
    > Anybody...???
    >
    > TIA
    > Neal
    >
    > Code....
    > 'checks to see read functionality
    > key = Registry.CurrentUser.OpenSubKey("SOFTWARE\SPLUS\pwd")
    > key.GetValue("pwd")
    >
    > Dim f As New
    > RegistryPermission(RegistryPermissionAccess.AllAccess, _
    > "HKEY_CURRENT_USER\SOFTWARE")
    > f.AddPathList(RegistryPermissionAccess.Write,
    > "HKEY_CURRENT_USER\SOFTWARE")
    > f.AddPathList(RegistryPermissionAccess.Write,
    > "HKEY_CURRENT_USER\SOFTWARE\SPLUS")
    > f.AddPathList(RegistryPermissionAccess.Write,
    > "HKEY_CURRENT_USER\SOFTWARE\SPLUS\pwd")
    >
    > f.Assert()
    >
    > key.SetValue("pwd", sValIn) 'cannot write to the registry
    > key
    >
    >
    > --------------------------------
    > From: Neal Rogers
    >
    > -----------------------
    > Posted by a user from .NET 247 (http://www.dotnet247.com/)
    >
    > <Id>AXHq1s34gUao3PPwNtbdMw==</Id>
     
    Nicole Calinoiu, Mar 18, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Q2hyaXMgTW9oYW4=?=

    Configuring Windows Auth & Forms Auth in Asp.Net

    =?Utf-8?B?Q2hyaXMgTW9oYW4=?=, Apr 28, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    706
    =?Utf-8?B?Q2hyaXMgTW9oYW4=?=
    Apr 28, 2004
  2. =?Utf-8?B?ZGhucml2ZXJzaWRl?=

    Windows Auth, but Forms Auth for one page?

    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Jan 8, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    570
    Elton Wang
    Jan 8, 2005
  3. Mark Chai
    Replies:
    1
    Views:
    742
    Christophe Vanfleteren
    Oct 1, 2003
  4. Chris Mohan

    Configuring Windows Auth & Forms Auth in Asp.Net

    Chris Mohan, Apr 28, 2004, in forum: ASP .Net Security
    Replies:
    2
    Views:
    433
    Chris Mohan
    Apr 29, 2004
  5. Forms Auth Info passed to Windows Auth?

    , Apr 28, 2005, in forum: ASP .Net Security
    Replies:
    1
    Views:
    222
    Hernan de Lahitte
    May 3, 2005
Loading...

Share This Page