Re: Registry Error "Access to the Registry Key HKEY_LOCAL..\. is d

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Neal (Neal_at_discussions.microsoft.com)
Date: 03/10/05


Date: Thu, 10 Mar 2005 01:05:02 -0800

Ok, well not ok.
I tried it with HKEY _CURRENT_USER,... and still the same result.
"Access to the Registry Key .... is denied

(It is my own machine, I have Admin rights....)
3 days wasted...trying to get something supposedly simple right, which took
me all of 5 minutes in Delphi (and I've only had 3 months experience
there..!!)

and then I suppose this will all be revisited upon deploying it to the
Production Server.

Seriously Frustrated

SO... NOW WHERE TO ???

Heres the code..
'//I try and create the subkey "UCT-SPLUS" in HKEY_CURRENT_USER\Software

ie
        Try
            Dim f As New
RegistryPermission(RegistryPermissionAccess.AllAccess, _
                "HKEY_CURRENT_USER\Software")
            f.AddPathList(RegistryPermissionAccess.Write,
"HKEY_CURRENT_USER\Software\UCT-SPLUS")
            f.Assert()

            Dim subkey As RegistryKey =
Registry.CurrentUser.CreateSubKey("Software\UCT-SPLUS\DbPwd")
            subkey.SetValue("DBPwd", sPwdValue)
        Catch ER As Exception
            Throw New Exception("Error writing to Registry : " & ER.Message)
        End Try

TIA
Neal

"Sean Hederman" wrote:

> "Neal" <Neal@discussions.microsoft.com> wrote in message
> news:BAF0A2E3-2558-45D3-8CE4-821AAEB3812F@microsoft.com...
> >I am attempting to write an encrypted password to the Registry, from a VB
> > ASP.Net App and similarly read it in a Webservice .
>
> A web service/app generally logs in as the user IUSER_MACHINENAME.
>
> > I have tried the RegistryPermissions code etc from the MSDN help,
> > Dim f As New
> > RegistryPermission(RegistryPermissionAccess.AllAccess, _
> > "HKEY_LOCAL_MACHINE\SOFTWARE\")
> > f.Assert()
> > ?? how does one tie this up to the RegistryKey class?? if at all.
>
> It means that the code is requesting permission to access that registry key.
> However, just because the code is trusted enough to access said registry
> key, does not mean that the user is. Basically the permissions you have are
> the intersection of the code and user permissions. Your code has the
> relevant CAS (code access security) permissions, but IUSER_MACHINENAME does
> not. Therefore, you get the permission denied error. In order for this to
> work, but the code and the user must have the relevant permissions.
>
> Generally the HKEY_LOCAL_MACHINE\SOFTWARE\ can only be written to by an
> Administrator, and for very good security reasons. Should this key really be
> getting stored there? Keep in mind that most (hopefully all) administrators
> will not allow IIS to have Administrator privileges, and convincing
> administrators to open up registry access to IIS will be tricky.
>
> > but .. the error persists.
> > (
> > I am currently trying to develop this on my DevMachine, (Administrator
> > rights etc), though this will need to be deployed to a Windows 2000 server
> > or
> > similar.
> >
> > Lost (......yet again !) ..
> > Anybody...?
> > TIA
> >
> > Code is as follows
> >
> > Dim subkey As RegistryKey =
> > Registry.LocalMachine.CreateSubKey("SOFTWARE\UCT-SPLUS\DbPwd")
> >
> > which is where the error occurs.. thereafter one assumes the setValue will
> > work.
> >
> > subkey.SetValue("DBPwd", sPwdValue)
> >
> >
> > --
> > Neal Rogers
> > University of Cape Town
>
>
>



Relevant Pages

  • Re: Service Pack 3 - Access Denied?
    ... resetting registry key permissions trashed my system every single time - it ... You may think you are the Administrator, but in reality you probably aren't. ... If your logged-in account identity is labeled "Computer Administrator" (under ... operating system files and the all branches of the "Windows Registry." ...
    (microsoft.public.windowsupdate)
  • Re: 0x80070005 / _Inventory: Installer returned 0x5 (5)
    ... |> Access Denied is a hard one to determine where the keys are failing - ... Navigate to the following key in the registry: ... and then click Permissions. ... |> For Administrator and System, select the Allow check boxes next to Full Control ...
    (microsoft.public.windowsupdate)
  • RE: services running in windows domain (winXP clients)
    ... registry changes and permissions. ... i mean if someone is administrator can change the ... (Maybe create a group policy setting this ...
    (Focus-Microsoft)
  • Re: How do I make registry changes stick?
    ... caused a duplicate but set of permissions to appear in the box. ... In the Registry Editor, right click.. ... take ownership of the registry key by the current owner. ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: How do I make registry changes stick?
    ... MS-MVP Windows Shell/User ... I found that the permissions for the key were and on the ... In the Registry Editor, right click.. ... take ownership of the registry key by the current owner. ...
    (microsoft.public.windowsxp.perform_maintain)