Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Problems using RegistryKey.OpenRemoteBaseKey()

Problems using RegistryKey.OpenRemoteBaseKey()

Scheduled Pinned Locked Moved C#
sysadminwindows-adminsecurityhelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    b_girl
    wrote on last edited by
    #1

    Hey, I keep getting the UnauthorisedAccessException from the following code - the user account I'm using to connect to the server in question does have permission to read/edit the registry. I have also modified the my routing table so I can access the server resources by name. If anyone could help me out I'd greatly appreciate it. using System; using System.Security; using System.Security.Permissions; using Microsoft.Win32; [assembly: RegistryPermissionAttribute(SecurityAction.RequestMinimum, Read = @"HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\VirusScan Engine\4.0.xx")] [assembly: SecurityPermissionAttribute(SecurityAction.RequestMinimum, UnmanagedCode = true)] String KEY = "SOFTWARE\\Network Associates\\TVD\\Shared Components\\VirusScan Engine\\4.0.xx"; try { RegistryHive hKey = RegistryHive.LocalMachine; RegistryKey DATKey = RegistryKey.OpenRemoteBaseKey(hKey, _ServerName).OpenSubKey(KEY); } ... It seems to get past the RegistryHive.LocalMachine part, but throws the exception when it gets to the open remote base key call. I tried separating the OpenRemoteBaseKey() and OpenSubKey() calls into 2 separate lines, to see if it was maybe OpenSubKey() that was throwing it, but the same exception was thrown on the OpenRemoteBaseKey() call. Thanks.

    L 1 Reply Last reply
    0
    • B b_girl

      Hey, I keep getting the UnauthorisedAccessException from the following code - the user account I'm using to connect to the server in question does have permission to read/edit the registry. I have also modified the my routing table so I can access the server resources by name. If anyone could help me out I'd greatly appreciate it. using System; using System.Security; using System.Security.Permissions; using Microsoft.Win32; [assembly: RegistryPermissionAttribute(SecurityAction.RequestMinimum, Read = @"HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\VirusScan Engine\4.0.xx")] [assembly: SecurityPermissionAttribute(SecurityAction.RequestMinimum, UnmanagedCode = true)] String KEY = "SOFTWARE\\Network Associates\\TVD\\Shared Components\\VirusScan Engine\\4.0.xx"; try { RegistryHive hKey = RegistryHive.LocalMachine; RegistryKey DATKey = RegistryKey.OpenRemoteBaseKey(hKey, _ServerName).OpenSubKey(KEY); } ... It seems to get past the RegistryHive.LocalMachine part, but throws the exception when it gets to the open remote base key call. I tried separating the OpenRemoteBaseKey() and OpenSubKey() calls into 2 separate lines, to see if it was maybe OpenSubKey() that was throwing it, but the same exception was thrown on the OpenRemoteBaseKey() call. Thanks.

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      b_girl wrote:

      UnauthorisedAccessException

      It means you have to be authenticated and have permissions on the server.

      **

      xacc.ide-0.2.0.50 - now with partial MSBuild support!

      **

      B 1 Reply Last reply
      0
      • L leppie

        b_girl wrote:

        UnauthorisedAccessException

        It means you have to be authenticated and have permissions on the server.

        **

        xacc.ide-0.2.0.50 - now with partial MSBuild support!

        **

        B Offline
        B Offline
        b_girl
        wrote on last edited by
        #3

        I am authenticating with the server and the account I'm authenticating with has permission to read/edit the registry. I'm doing the authentication when I connect - I'm using the Ras API to establish a VPN connection to the server. Do I have to authenticate again after the connection is established?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups