How can you get the terminal service client machine name from javascript?

回眸只為那壹抹淺笑 提交于 2019-12-11 05:58:17

问题


Is it possible to get the machine name, or IP, or MAC address (basically client network information) from javascript running Internet Explorer?

I found the following code that seems to accomplish this:

function Button1_onclick() {
  var locator = new ActiveXObject("WbemScripting.SWbemLocator");
  var service = locator.ConnectServer(".");
  var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
  var e = new Enumerator (properties);
  document.write("<table border=1>");
  dispHeading();
  for (;!e.atEnd();e.moveNext ())
  {
        var p = e.item ();
        document.write("<tr>");
        document.write("<td>" + p.Caption + "</td>");
        document.write("<td>" + p.IPFilterSecurityEnabled + "</td>");
        document.write("<td>" + p.IPPortSecurityEnabled + "</td>");
        document.write("<td>" + p.IPXAddress + "</td>");
        document.write("<td>" + p.IPXEnabled + "</td>");
        document.write("<td>" + p.IPXNetworkNumber + "</td>");
        document.write("<td>" + p.MACAddress + "</td>");
        document.write("<td>" + p.WINSPrimaryServer + "</td>");
        document.write("<td>" + p.WINSSecondaryServer + "</td>");
        document.write("</tr>");
  }
  document.write("</table>");

}

So it's using an ActiveX Object that seems to be installed with the OS to accomplish this. Is something similar like this possible to do from a terminal service session? To get the terminal service client network information? (Not the terminal server network information which is what the above code would do when run from a terminal service session).

I'm thinking maybe there is another Active X object available to accomplish this?


回答1:


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

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

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.

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);



回答2:


If a user is logged onto a Terminal Server and visits a page in Internet Explorer in that TS session, then Internet Explorer (and any ActiveX controls it instantiates) are running on the Terminal Server hardware, not the client hardware.

From this perspective, the only code running on the client hardware is the Terminal Services client software. To retrieve network information about the Terminal Services client hardware/network/etc, you would have to run code on the client hardware.



来源:https://stackoverflow.com/questions/192839/how-can-you-get-the-terminal-service-client-machine-name-from-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!