0

I'm trying to get the IP address of the RDP client so we can keep record of everyone who is connecting to our server and at what times. Is there a way to do this using VB.net? Everything I've tried just returns the IP address of the server.

Thanks!

  • Do you have anymore information on your RDP connection settings or logging or anything? I would try to answer your question but I do not have enough information on your RDP settings to do so. For instance, is the RDP client connecting over VPN or local? This makes a big difference. – jeffery Aug 09 '13 at 17:49
  • Currently the RDP is running on a local network but in time will be rolled out to external clients. The RDP when it loads it only loads Internet Explorer not the whole desktop – Anthony Collins Aug 13 '13 at 08:09

1 Answers1

0

An excerpt from the actual code what you are looking for.

 Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim serverName As String
        Dim clientInfo As New WTS_CLIENT_INFO
        ReDim clientInfo.Address(20)
        serverName = ""
        'Server Name can be name of choice or name of server on which this application is running
        If GetSessions(serverName, clientInfo) = True Then
            Dim str As String
            str = "User Name: " & clientInfo.WTSUserName
            str &= vbNewLine & "Station Name: " & clientInfo.WTSStationName
            str &= vbNewLine & "Domain Name: " & clientInfo.WTSDomainName
            If clientInfo.WTSStationName <> "Console" Then
                str &= vbNewLine & "Client Name: " & clientInfo.WTSClientName
                str &= vbNewLine & "Client IP: " & clientInfo.Address(2) & "." & clientInfo.Address(3) & "." & clientInfo.Address(4) & "." & clientInfo.Address(5)
            End If
            MessageBox.Show(str)
        End If
    End Sub
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
  • Thanks for your response, I tried your solution and it runs but it gives me a IP address that is in Japan somewhere, when I refresh the page it gives me a completely different IP address – Anthony Collins Aug 09 '13 at 09:41
  • you want to know the IP Address only? why dont you post a http call then obtain the response in string (parse) it lastly... as you're requested.... – gumuruh Apr 22 '20 at 10:10