I'm trying to return from a webpage, the remote HKCU\Volatile\C LIENTNAME
Here's what I'm doing so far:
Get the Machine Name via DNS - this bit works great:
Then using that information, attempt to access the registry and pull the value:
Remote Registry Function
So this works if I run it from the Hostmachine, but not if I run it from remote machines.
Here's what I'm doing so far:
Get the Machine Name via DNS - this bit works great:
Code:
Public Shared Function GetMachineName(ByVal sender As System.Web.UI.Control) As String Dim host As System.Net.IPHostEntry = Nothing Dim machinename As String = "" host = System.Net.Dns.GetHostEntry(sender.Page.Request.ServerVariables("REMOTE_ADDR")) machinename = host.HostName Return UCase(machinename).Replace(".CELLNETIX.LOCAL", "") End Function
Code:
Public Shared Function getClientName(Optional ByVal MachineName As String = "localhost") As String Dim strReturn As String = "" strReturn = regValue(RegistryHive.CurrentUser, "Volatile Environment", "CLIENTNAME", MachineName) Return strReturn
Code:
Public Shared Function regValue(ByVal hive As RegistryHive, _ ByVal key As String, _ ByVal ValueName As String, _ Optional ByVal MachineName As String = "localhost", _ Optional ByRef ErrInfo As String = "") As String Dim objParent As RegistryKey = Nothing Dim objSubkey As RegistryKey = Nothing Dim sAns As String = "" Select Case hive Case RegistryHive.ClassesRoot objParent = RegistryKey.OpenRemoteBaseKey(RegistryHive.ClassesRoot, MachineName) Case RegistryHive.CurrentConfig objParent = RegistryKey.OpenRemoteBaseKey(RegistryHive.CurrentConfig, MachineName) Case RegistryHive.CurrentUser objParent = RegistryKey.OpenRemoteBaseKey(RegistryHive.CurrentUser, MachineName) Case RegistryHive.DynData objParent = RegistryKey.OpenRemoteBaseKey(RegistryHive.DynData, MachineName) Case RegistryHive.LocalMachine objParent = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, MachineName) Case RegistryHive.PerformanceData objParent = RegistryKey.OpenRemoteBaseKey(RegistryHive.PerformanceData, MachineName) Case RegistryHive.Users objParent = RegistryKey.OpenRemoteBaseKey(RegistryHive.Users, MachineName) End Select Try objSubkey = objParent.OpenSubKey(key) If Not IsNothing(objSubkey) Then sAns = (objSubkey.GetValue(ValueName)).ToString End If Catch ex As Exception ErrInfo = ex.Message Finally If ErrInfo = "" And sAns = "" Then ErrInfo = _ "No value found for requested registry key" End If End Try Return sAns End Function
Comment