Beispiel #1
0
        private static IEnumerable <VssCredentials> CredentialsFactory(AuthenticationTypes t)
        {
            if (t.HasFlag(AuthenticationTypes.OpenAuthorization))
            {
                foreach (var cred in Qwiq.Credentials.CredentialsFactory.GetOAuthCredentials())
                {
                    yield return(cred);
                }
            }

            if (t.HasFlag(AuthenticationTypes.PersonalAccessToken))
            {
                foreach (var cred in Qwiq.Credentials.CredentialsFactory.GetServiceIdentityPatCredentials())
                {
                    yield return(cred);
                }
            }

            if (t.HasFlag(AuthenticationTypes.Windows))
            {
                foreach (var cred in Qwiq.Credentials.CredentialsFactory.GetServiceIdentityCredentials())
                {
                    yield return(cred);
                }
            }

            if (t.HasFlag(AuthenticationTypes.Basic))
            {
                foreach (var cred in Qwiq.Credentials.CredentialsFactory.GetBasicCredentials())
                {
                    yield return(cred);
                }
            }

            if (t.HasFlag(AuthenticationTypes.Windows))
            {
                var storage = new VssClientCredentialStorage();

                // User did not specify a username or a password, so use the process identity
                yield return(new VssClientCredentials(new WindowsCredential(false))
                {
                    Storage = storage,
                    PromptType = CredentialPromptType.DoNotPrompt
                });

                // Use the Windows identity of the logged on user
                yield return(new VssClientCredentials(true)
                {
                    Storage = storage, PromptType = CredentialPromptType.PromptIfNeeded
                });
            }
        }
Beispiel #2
0
 public void Bind(LoginInfo loginInfo, string password, AuthenticationTypes authenticationType)
 {
     using (var ldapConnection = new LdapConnection(loginInfo.Domain)
     {
         AuthType = AuthType.Negotiate
     })
     {
         ldapConnection.SessionOptions.SecureSocketLayer = authenticationType.HasFlag(AuthenticationTypes.SecureSocketsLayer);
         ldapConnection.Bind(new NetworkCredential(loginInfo.UserName, password, loginInfo.Domain));
     }
 }
Beispiel #3
0
        private static IEnumerable <VssCredentials> UnitTestCredentialsFactory(AuthenticationTypes types)
        {
            if (types.HasFlag(AuthenticationTypes.Windows))
            {
                // User did not specify a username or a password, so use the process identity
                yield return(new VssClientCredentials(new WindowsCredential(false))
                {
                    Storage = new VssClientCredentialStorage(), PromptType = CredentialPromptType.DoNotPrompt
                });

                if (IsContiniousIntegrationEnvironment)
                {
                    yield break;
                }

                // Use the Windows identity of the logged on user
                yield return(new VssClientCredentials(true)
                {
                    Storage = new VssClientCredentialStorage(), PromptType = CredentialPromptType.PromptIfNeeded
                });
            }
        }