C#如何注销Citrix XenApp用户会话?
由于Citrix在其SDK上的文档绝对为零,所以在此进行文档记录.
使用C#,如何以编程方式注销用户会话?
解决方法:
使用下面的简单方法通过解析会话并注销单个会话来注销用户会话.
using Citrix.Common.Sdk;
using Citrix.XenApp.Sdk;
using Citrix.XenApp.Commands;
using Citrix.Management.Automation;
private void logoffUser(string strUser)
{
GetXASessionByFarm sessions = new GetXASessionByFarm(true);
foreach (XASession session in CitrixRunspaceFactory.DefaultRunspace.ExecuteCommand(sessions))
{
if (session.AccountName.ToLower() == objWINSDomainName + "\\" + strUser)
{
var cmd = new StopXASessionByObject(new[] { session });
CitrixRunspaceFactory.DefaultRunspace.ExecuteCommand(cmd);
}
}
}