/// <summary>
        /// Runs property autodetection.
        /// </summary>
        /// <returns>Return true if the function is succeeded.</returns>
        public bool RunDetection()
        {
            // set config if properties changed
            config.ServerDomain = properties[RDPValueDetector.ServerDomain];
            config.ServerName   = properties[RDPValueDetector.ServerName];
            config.ServerPort   = properties[RDPValueDetector.ServerPort];

            config.ServerUserName     = properties[RDPValueDetector.ServerUserName];
            config.ServerUserPassword = properties[RDPValueDetector.ServerUserPassword];
            config.ClientName         = properties[RDPValueDetector.ClientName];
            config.Version            = properties[RDPValueDetector.RDPVersion];

            if (!PingSUT())
            {
                return(false);
            }

            RDPDetector detector = new RDPDetector(detectionInfo);

            if (!detector.DetectRDPFeature())
            {
                detector.Dispose();
                return(false);
            }
            detector.Dispose();
            return(true);
        }
        /// <summary>
        /// Run auto detection properly.
        /// </summary>
        /// <returns>Return true if the function succeeded.</returns>
        public bool RunDetection(DetectContext context)
        {
            logWriter.ApplyDetectContext(context);

            try
            {
                if (context.Token.IsCancellationRequested)
                {
                    return(false);
                }

                logWriter.AddLog(DetectLogLevel.Information, "Detect Client HostName...");

                // set config if properties changed
                config.ServerName   = properties[RDPValueDetector.ServerName];
                config.ServerDomain = properties[RDPValueDetector.ServerDomain];
                if (config.ServerDomain != null && config.ServerDomain.Length == 0)
                {
                    config.ServerDomain = config.ServerName;
                }
                config.ServerPort         = properties[RDPValueDetector.ServerPort];
                config.ServerUserName     = properties[RDPValueDetector.ServerUserName];
                config.ServerUserPassword = properties[RDPValueDetector.ServerUserPassword];
                config.ClientName         = Dns.GetHostName();
                logWriter.AddLog(DetectLogLevel.Warning, "Finished", false, LogStyle.StepPassed);

                if (context.Token.IsCancellationRequested)
                {
                    return(false);
                }

                if (!DetectSUTIPAddress())
                {
                    return(false);
                }

                using (var detector = new RDPDetector(detectionInfo, logWriter))
                {
                    if (!detector.DetectRDPFeature(config))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                logWriter.AddLog(DetectLogLevel.Warning, "Failed", false, LogStyle.StepFailed);
                logWriter.AddLog(DetectLogLevel.Information, String.Format("RunDetection() threw exception: {0}", ex));
                logWriter.AddLog(DetectLogLevel.Information, ex.StackTrace);
                return(false);
            }
        }
示例#3
0
        /// <summary>
        /// Run auto detection properly.
        /// </summary>
        /// <returns>Return true if the function succeeded.</returns>
        public bool RunDetection()
        {
            try
            {
                DetectorUtil.WriteLog("Detect Client HostName...");

                // set config if properties changed
                config.ServerName   = properties[RDPValueDetector.ServerName];
                config.ServerDomain = properties[RDPValueDetector.ServerDomain];
                if (config.ServerDomain != null && config.ServerDomain.Length == 0)
                {
                    config.ServerDomain = config.ServerName;
                }
                config.ServerPort         = properties[RDPValueDetector.ServerPort];
                config.ServerUserName     = properties[RDPValueDetector.ServerUserName];
                config.ServerUserPassword = properties[RDPValueDetector.ServerUserPassword];
                config.ClientName         = Dns.GetHostName();

                DetectorUtil.WriteLog("Finished!", false, LogStyle.StepPassed);

                if (!PingSUT())
                {
                    return(false);
                }

                using (var detector = new RDPDetector(detectionInfo))
                {
                    if (!detector.DetectRDPFeature(config))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                DetectorUtil.WriteLog(String.Format("RunDetection() threw exception: {0}", ex));
                return(false);
            }
        }