Exemplo n.º 1
0
        public void UpdateSessionWatchers(object state)
        {
            int[]     winSessions  = WTSEngine.GetActiveSessions();
            Process[] rcdProcesses = GetRcordingProcesses();

            _watchers.Clear();
            foreach (int wsid in winSessions)
            {
                var watcher = new SessionWatcher()
                {
                    WinSessionId = wsid
                };
                _watchers.Add(watcher);

                var proc = Array.Find(rcdProcesses, p => p.SessionId == wsid);
                if (proc != null)
                {
                    watcher.RecordProcess = proc;
                    watcher.State         = SessionState.Recording;
                }
                else
                {
                    string user = WTSEngine.GetDomainUserBySessionId(wsid);
                    if (UserPolicy.IsUserRecording(user))
                    {
                        // logon
                    }
                    else
                    {
                        watcher.State = SessionState.Exclude;
                    }
                }
            }
        }
Exemplo n.º 2
0
 public void SessionLogoff(int winSessionId)
 {
     try
     {
         if (_watchers.ContainsKey(winSessionId))
         {
             SessionWatcher sw = _watchers[winSessionId] as SessionWatcher;
             _watchers.Remove(winSessionId);
             new CacheManager().WriteSessionEnd(sw.RcdSessionId);
         }
     }
     catch (Exception ex) { TraceLogger.Instance.WriteException(ex); }
 }
Exemplo n.º 3
0
        public void SessionLogon(int winSessionId)
        {
            if (!Global.Config.RecordEnabled)
            {
                return;
            }
            try
            {
                while (!WTSEngine.IsSessionActive(winSessionId))
                {
                    System.Threading.Thread.Sleep(1000);
                }

                //if (checkUserPolicy && (!IsUserRecording(winSessionId)))
                //    return;

                string rcdSessionId = Guid.NewGuid().ToString("n");
                string rcdProgram   = System.IO.Path.Combine(Application.StartupPath, "rcda.exe");
                int    pid;
                if (bfbd.Common.OSVersion.IsVista)
                {
                    pid = ProcessEngine.CreateProcessAsAdmin(winSessionId, rcdProgram, rcdSessionId);
                }
                else
                {
                    pid = ProcessEngine.CreateProcessAsUser(winSessionId, rcdProgram, rcdSessionId);
                }

                if (pid != 0)
                {
                    TraceLogger.Instance.WriteLineInfo("Record process has started.");
                    TraceLogger.Instance.WriteLineInfo(string.Format("winSessionId={0}, ProcessId={1}, rcdSessionId={2}", winSessionId, pid, rcdSessionId));

                    SessionWatcher watcher = new SessionWatcher()
                    {
                        WinSessionId = winSessionId,
                        RcdSessionId = rcdSessionId,
                        ProcessId    = pid,
                    };
                    _watchers[winSessionId] = watcher;
                }
                else
                {
                    TraceLogger.Instance.WriteLineError("CreateProcessAsUser Fail. SessionId=" + winSessionId);
                }
            }
            catch (Exception ex) { TraceLogger.Instance.WriteException(ex); }
        }