BUG: The WTSQuerySessionInformation() Function Returns Invalid Client Address (238143)
The information in this article applies to:
- Microsoft Windows NT Server 4.0
This article was previously published under Q238143 SYMPTOMS
You should use the WTSQuerySessionInformation function with the filtering flag, WTSClientAddress, to get the client IP address on a Windows Terminal Client. The buffer that is returned by this function contains a WTS_CLIENT_ADDRESS structure for the client address family and address. However, on Windows NT Server version 4.0, Terminal Server Edition (TS4), the client address field is invalid.
RESOLUTION
As a workaround on TS4, you can first use the WTSQuerySessionInformation function with the WTSClientName filtering flag to get the client name. The client name is either a dotted IP address or a name string. If the client name is a name string, use the gethostbyname function to resolve the name to an IP address.
The following code fragment illustrates how to use the gethostbyname function to resolve a client name string to its IP address:
...
...
...
lphp = gethostbyname(szClientName);
if (lphp == NULL)
{
printf("gethostbyname failed: %d", WSAGetLastError());
return -1;
}
inAddr.s_addr = ((struct in_addr far *)(lphp->h_addr))->s_addr;
printf("Client address: %s\n", inet_ntoa(inAddr));
...
...
...
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. MORE INFORMATION
Because of this bug, both the auditing event log and tsadmin do not show the IP address of the client.
Modification Type: | Major | Last Reviewed: | 10/15/2002 |
---|
Keywords: | kbAPI kbBug kbDSupport kbnetwork KB238143 |
---|
|