且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从javascript获取终端服务客户端计算机名称?

更新时间:2022-06-23 22:21:59

基本上,有两种方法可以想到客户名称/地址:

Basically, there are two possibilities to get hold of the client name/address that come to mind:


  • 使用MFCOM,即 MetaFrameSession 对象。

  • 使用WMI, root\Citrix 中的 MetaFrame_ICA_Client 类看起来很有希望。

  • Use MFCOM, namely the MetaFrameSession object.
  • Use WMI, the MetaFrame_ICA_Client class in root\Citrix looks promising.

这两种解决方案的市长缺点是,它们需要的用户权限超出了您可能愿意提供的权限。根据我的阅读,Citrix至少需要帐户查看权限,但是我目前无法对其进行测试。我不能以普通用户的身份工作。

Mayor drawback of both solutions is, that they require more user permissions than you might be willing to give. From what I read, at least "Account View" permissions are required within Citrix, but I have no way to test it right now. I could not get either to work as a normal user.

为了给您一个想法,使用MFCOM访问信息看起来像这样:

To give you an idea, accessing the info with MFCOM would look something like this:

var MetaFrameSessionObject = 6;

var oShell   = new ActiveXObject("WScript.Shell");
var oSession = new ActiveXObject("MetaFrameCOM.MetaFrameSession");

oSession.Initialize(
  MetaFrameSessionObject, 
  oShell.ExpandEnvironmentStrings("%COMPUTERNAME%"), 
  oShell.ExpandEnvironmentStrings("%SESSIONNAME%"), 
  -1
);

alert(oSession.ClientAddress);