0

目前对于 Presentation Server 4.0 和 4.5,我正在通过 C# .NET 中的 MFCom 获取唯一的客户端 ID。

MetaFrameFarm farm = new MetaFrameFarm();
farm.Initialize(MetaFrameObjectType.MetaFrameWinFarmObject);

foreach (MetaFrameSession session in farm.Sessions)
{
    clientId = session.ClientID;
.....

我开始在 6.0 上进行错误测试。有问题的行是实例化上述对象“农场”的第一行。

上网查了一下,发现这个...

从 XenApp 6.0 开始,MFCOM 作为公共支持的编程和脚本接口将不再可用。所有现有的基于 MFCOM 的代码不再适用于 XenApp 6.0。毫无疑问,没有 MFCOM 将需要额外的努力才能采用 XenApp 6.0。

有没有办法在 6.0 中获得唯一的客户端 ID?

4

2 回答 2

1

这已经很老了,但是当我想获得 clientID 时,我一直在遇到这个问题。

请记住,来自 4.X 的 ClientID 似乎与 6.X 的格式不同。这适用于所有 ID、应用程序和服务器:

Runspace rs = RunspaceFactory.CreateRunspace();
rs.Open();

PowerShell ps = PowerShell.Create();
ps.Runspace = rs;

PSSnapInException ex;
rs.RunspaceConfiguration.AddPSSnapIn("Citrix.XenApp.Commands", out ex);

ps.AddCommand("GET-XASession").AddParameter("Full");

foreach (PSObject Session in ps.Invoke())
{
   try
   {
      ClientID = Convert.ToString(Session.Properties["ClientId"].Value);

      Console.WrileLine(ClientID);

   }

   catch (Exception e)
   {
      WriteError.WriteEntry("Client Failure " + e.Message + EventLogEntryType.FailureAudit);
   }
}
于 2011-11-08T22:28:01.110 回答
0

As you've correctly established, MFCOM is not available on XenApp 6. So, you're left with two ways of getting a unique ClientID:

  1. Use the Citrix WMI subsystem. From within your application, connect to the Root\Citrix WMI namespace and enumerate instances of the MetaFrame_Session class. You can filter by server name (as the enumeration will return all sessions on all farm servers, not just the one you're running the application on) and session ID. The instances of the Metaframe_session class contain a couple of properties which are references to instances of other classes; the Client property references Metaframe_ICA_Client and the SessionUser property references Citrix_User. Metaframe_ICA_Client gives you the client's IP address, hostname and a few other things you could combine as an ID.
    However, currently XenApp 6 has a massive bug with the Citrix WMI subsystem and attempting to enumerate and instantiate the classes I've references above (as a normal user - admins are fine) results in no less than fifteen separate system services crashing... So maybe not.
  2. The alternative (and the technique I employed) was to use the Citrix WFAPI SDK. It's unmanaged code and a bit of a pig, but there's a pretty good article on using WFAPI to grab client details here.
于 2011-08-23T14:21:45.940 回答