Exemplo n.º 1
0
        private void EnableClientCredSSP()
        {
            var localPsExecutor = new PowerShellExecutor();
            var result          = localPsExecutor.ExecuteLocal(_server, @"get-item -Path wsman:\localhost\Client\Auth\CredSSP",
                                                               mod => mod.LoadConDepModule = false).ToList();

            if (result.Count != 1)
            {
                throw new ConDepCredSSPException();
            }

            bool credSspEnabled;

            if (!bool.TryParse(result.First().Value, out credSspEnabled))
            {
                throw new ConDepCredSSPException("Unable to retreive CredSSP value for this client.");
            }

            if (!credSspEnabled)
            {
                Logger.Verbose("CredSSP for client not enabled. Temporarly enabling now for this execution.");
                localPsExecutor.ExecuteLocal(_server, @"set-item -path wsman:\localhost\Client\Auth\CredSSP -value 'true'",
                                             mod => mod.LoadConDepModule = false);

                _cleanupFunctions.Add(() => localPsExecutor.ExecuteLocal(_server,
                                                                         @"set-item -path wsman:\localhost\Client\Auth\CredSSP -value 'false'", mod => mod.LoadConDepModule = false));
            }

            EnableFreshCredentials(REG_KEY_ALLOW_FRESH_CREDENTIALS);
            if (!IsDomainUser())
            {
                EnableFreshCredentials(REG_KEY_ALLOW_FRESH_CREDENTIALS_WHEN_NTLM_ONLY);
            }
        }
Exemplo n.º 2
0
        private void EnableClientCredSSP()
        {
            var localPsExecutor = new PowerShellExecutor();
            var result = localPsExecutor.ExecuteLocal(_server, @"get-item -Path wsman:\localhost\Client\Auth\CredSSP", mod => mod.LoadConDepModule = false).ToList();

            if (result.Count != 1) throw new ConDepCredSSPException();

            bool credSspEnabled;
            if (!Boolean.TryParse(result.First().Value, out credSspEnabled))
            {
                throw new ConDepCredSSPException("Unable to retreive CredSSP value for this client.");
            }

            if (!credSspEnabled)
            {
                Logger.Verbose("CredSSP for client not enabled. Temporarly enabling now for this execution.");
                localPsExecutor.ExecuteLocal(_server, @"set-item -path wsman:\localhost\Client\Auth\CredSSP -value 'true'", mod => mod.LoadConDepModule = false);

                _cleanupFunctions.Add(() => localPsExecutor.ExecuteLocal(_server, @"set-item -path wsman:\localhost\Client\Auth\CredSSP -value 'false'", mod => mod.LoadConDepModule = false));
            }

            EnableFreshCredentials(REG_KEY_ALLOW_FRESH_CREDENTIALS);
            if(!IsDomainUser())
            {
                EnableFreshCredentials(REG_KEY_ALLOW_FRESH_CREDENTIALS_WHEN_NTLM_ONLY);
            }
        }
Exemplo n.º 3
0
        public void TestThat_Something()
        {
            ConDep.Dsl.Logging.Logger.Initialize(CreateMemoryLogger());

            var executor = new PowerShellExecutor();
            var result = executor.ExecuteLocal(new ServerConfig(), "$psVersionTable.PSVersion.Major", load => load.LoadConDepModule = false);

            //var versionResult = GetExecutionResult();

            ////---------------------------
            var version = result.First();
            //dynamic version = ((Collection<PSObject>)versionResult).First();
            Assert.That(version >= 3);
        }