3

Since there is absolutely zero documentation by Citrix on their SDK, I am documenting this here.

Using C#, how do I programmatically log a user session off?

4

1 回答 1

3

使用下面的简单方法通过解析会话并注销单个会话来注销用户会话。

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);
            }
        }
    }
于 2015-01-23T21:11:39.690 回答