コード例 #1
0
        private RaSofOperation StopRemoteDesktop(RaSofOperation operation)
        {
            Logger.Info("Stopping remote desktop.");

            try
            {
                operation.Api = RaUrn.RdResults + "|||" + HttpMethods.Post;
                //operation.RequestMethod = HttpMethods.Post;

                bool   tunnelStopped = Tunnel.StopReverseTunnel();
                bool   rdStopped     = RemoteDesktop.StopService();
                string error         = String.Empty;

                if (!tunnelStopped)
                {
                    error = "Unable to stop tunnel. ";
                }

                if (!rdStopped)
                {
                    error += "Unable to stop remote desktop service. ";
                }

                if (error != String.Empty)
                {
                    error += "Please see agent log for details.";
                }

                operation.Success = tunnelStopped && rdStopped;
                operation.Error   = error;
            }
            catch (Exception e)
            {
                string msg = "Unable to stop remote desktop password.";
                operation.Success = false;
                operation.Error   = String.Format("{0}. {1}", msg, e.ToString());

                Logger.Error(msg);
                Logger.Exception(e);
            }

            operation.RawResult = RaFormatter.StopRemoteResult(operation);

            Logger.Info("Done.");
            return(operation);
        }
コード例 #2
0
        private RaSofOperation SetRemoteDesktopPassword(RaSofOperation operation)
        {
            Logger.Info("Setting remote desktop password.");

            try
            {
                operation.Api = RaUrn.RdResults + "|||" + HttpMethods.Post;
                //operation.RequestMethod = HttpMethods.Post;

                if (operation.Password.Length >= 1)
                {
                    operation.Success = RemoteDesktop.SetTightVNCPassword(operation.Password);

                    if (!operation.Success)
                    {
                        operation.Error = "Unable to set remote desktop password. Please see log for more details.";
                    }
                }
                else
                {
                    operation.Success = false;
                    operation.Error   = "Password must be greater than one character.";
                }
            }
            catch (Exception e)
            {
                string msg = "Unable to set remote desktop password.";
                operation.Success = false;
                operation.Error   = String.Format("{0}. {1}", msg, e.ToString());

                Logger.Error(msg);
                Logger.Exception(e);
            }

            operation.RawResult = RaFormatter.StopRemoteResult(operation);

            Logger.Info("Done.");
            return(operation);
        }