I m试图书写一个文字,记录视窗客户的IP地址,用户从该地址开始将台式 Desktop登录到Windows服务器。 如何在服务器中捕获客户的IP地址?
如何获得远程桌面客户的IP地址?
原标题:How to get the IP Address of the Remote Desktop Client?
最佳回答
因此,你无视代理......
- using environment var: CLIENTNAME in domain you can resolve it back to IP
无域控制器:
- using WMI script you can get to Event Log, source: Security, look for category Logon/Logoff where username = environment variable USERNAME
问题回答
如果你想要使用“纯”权力2.0:
$Wtsapi32 = @
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace Wtsapi32 {
public enum WTS_INFO_CLASS
{
WTSInitialProgram,
WTSApplicationName,
WTSWorkingDirectory,
WTSOEMId,
WTSSessionId,
WTSUserName,
WTSWinStationName,
WTSDomainName,
WTSConnectState,
WTSClientBuildNumber,
WTSClientName,
WTSClientDirectory,
WTSClientProductId,
WTSClientHardwareId,
WTSClientAddress,
WTSClientDisplay,
WTSClientProtocolType
};
[StructLayout(LayoutKind.Sequential)]
public struct WTS_CLIENT_ADDRESS
{
public uint AddressFamily;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
public byte[] Address;
}
public class PS {
public const IntPtr WTS_CURRENT_SERVER_HANDLE = IntPtr.Zero;
public const int WTS_CURRENT_SESSION = -1;
[DllImport("wtsapi32.dll", EntryPoint="WTSQuerySessionInformation")]
public static extern bool WTSQuerySessionInformation(
System.IntPtr hServer,
int sessionId,
WTS_INFO_CLASS wtsInfoClass,
out System.IntPtr ppBuffer,
out uint pBytesReturned);
[DllImport("wtsapi32.dll", EntryPoint="WTSFreeMemory")]
public static extern void WTSFreeMemory(
IntPtr memory);
}
}
@
Add-Type -TypeDefinition $Wtsapi32
如果你使用PowerShell或A.NET语言,Cassia Library 仅支持这一内容——即从build服务器(博客作为客人,使用手工艺品链接)。 为了在本地服务器上印刷所有会议的远程地址,您可使用以下一些内容:
ITerminalServicesManager manager = new TerminalServicesManager();
foreach (ITerminalServicesSession session in manager.GetLocalServer().GetSessions())
{
IPEndPoint ipEndPoint = session.RemoteEndPoint as IPEndPoint;
if (ipEndPoint != null)
{
Console.WriteLine(ipEndPoint.Address);
}
}
相关问题
热门标签
- winforms
- combobox
- fogbugz
- java
- date
- internationalization
- asp.net
- iis
- url-rewriting
- urlrewriter
- c#
- enums
- ocaml
- haxe
- algorithm
- string
- viewstate
- .net
- c++
- c
- symbol-table
- mysql
- database
- postgresql
- licensing
- migration
- vb.net
- vb6
- declaration
- vb6-migration
- python
- psycopg2
- backup
- vmware
- virtualization
- gnu-screen
- authentication
- desktop
- excel
- xll
- cultureinfo
- regioninfo
- oracle
- client
- session
- download
- html
- virtual
- constructor
- scenarios
- perl
- full-text-search
- javascript
- ajax
- testing
- oop
- inheritance
- vim
- encapsulation
- information-hiding