Ejemplo n.º 1
0
        public bool LogoffSessions(WTSSessionList _Sessions)
        {
            bool rtn = true;

            string msg = "Are you sure want to logoff these sessions?" + Environment.NewLine + Environment.NewLine;

            foreach (WTSSession s in _Sessions)
            {
                msg += "   " + s.Hostname + ", " + s.Username + " (" + s.SessionId + ");" + Environment.NewLine;
            }
            MessageBoxResult result = System.Windows.MessageBox.Show(msg,
                                                                     "Confirm Logoff", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                foreach (WTSSession s_kill in _Sessions)
                {
                    if (s_kill.LogoffSession() == false)
                    {
                        rtn = false;
                    }
                }
            }
            this.RefreshList();
            return(rtn);
        }
Ejemplo n.º 2
0
        public bool LogoffAllSessionsForUser(string _Username)
        {
            bool           rtn         = true;
            string         username_lc = _Username.ToLower();
            WTSSessionList killlist    = new WTSSessionList();

            string msg = "Are you sure want to logoff these sessions?" + Environment.NewLine + Environment.NewLine;

            foreach (WTSSession s in this)
            {
                if (s.Username.ToLower() == username_lc)
                {
                    msg += "   " + s.Hostname + ", " + s.Username + " (" + s.SessionId + ");" + Environment.NewLine;
                    killlist.Add(s);
                }
            }
            MessageBoxResult result = System.Windows.MessageBox.Show(msg,
                                                                     "Confirm Logoff", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                foreach (WTSSession s_kill in killlist)
                {
                    if (s_kill.LogoffSession() == false)
                    {
                        rtn = false;
                    }
                }
            }
            this.RefreshList();
            return(rtn);
        }