C# How do I log off a Citrix XenApp User Session?

青春壹個敷衍的年華 提交于 2019-12-07 15:37:49

问题


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?


回答1:


Use the simple method below to log off a user session by parsing through sessions and logging off an individual session.

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


来源:https://stackoverflow.com/questions/28118799/c-sharp-how-do-i-log-off-a-citrix-xenapp-user-session

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