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!
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!
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