/// <summary>
        /// Configure the SOAP connection for HTTP or HTTPS depending on what was specified
        /// </summary>
        /// <param name="httpBinding"></param>
        /// <param name="uri"></param>
        /// <remarks>Allows self-signed certs to be used</remarks>
        public static void ConfigureBinding(BasicHttpBinding httpBinding, Uri uri)
        {
            //Handle SSL if necessary
            if (uri.Scheme == "https")
            {
                httpBinding.Security.Mode = BasicHttpSecurityMode.Transport;
                httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;

                //Allow self-signed certificates
                PermissiveCertificatePolicy.Enact("");
            }
            else
            {
                httpBinding.Security.Mode = BasicHttpSecurityMode.None;
            }
        }
 public static void Enact(string subjectName)
 {
     currentPolicy = new PermissiveCertificatePolicy(subjectName);
 }
        /// <summary>
        /// Authenticates the user from the providing server/login/password information
        /// </summary>
        /// <param name="sender">The sending object</param>
        /// <param name="e">The event arguments</param>
        private void btnAuthenticate_Click(object sender, System.EventArgs e)
        {
            try
            {
                //Disable the login and next button
                this.btnNext.Enabled = false;

                //Make sure that a login was entered
                if (this.txtLogin.Text.Trim() == "")
                {
                    MessageBox.Show("You need to enter a MTM login", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                //Make sure that a server was entered
                if (this.txtServer.Text.Trim() == "")
                {
                    MessageBox.Show("You need to enter a MTM server URL", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                //Enable self-signed certificates
                PermissiveCertificatePolicy.Enact("");

                TfsTeamProjectCollection tfsTeamProjectCollection;
                TestManagementService    testManagementService = GetMtmServiceInstance(out tfsTeamProjectCollection);

                if (testManagementService != null)
                {
                    MessageBox.Show("You have logged into MTM Successfully.\nPlease choose a Project from the list below:", "Authentication", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    //Now we need to populate the list of projects
                    ReadOnlyCollection <CatalogNode> projectNodes = tfsTeamProjectCollection.CatalogNode.QueryChildren(new[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None);

                    //Get the names into a simple list
                    List <string> projectNames = new List <string>();
                    foreach (CatalogNode projectNode in projectNodes)
                    {
                        if (projectNode.Resource != null)
                        {
                            string projectName = projectNode.Resource.DisplayName;
                            projectNames.Add(projectName);
                        }
                    }
                    this.cboProject.DataSource = projectNames;

                    //Also load in the test plans for this project
                    LoadTestPlansForProject();

                    //Enable the 'Next' button
                    this.btnNext.Enabled = true;
                }
            }
            catch (FileNotFoundException exception)
            {
                //This happens if the TFS client libraries are not available
                MessageBox.Show("Error Connecting to MTM. You need to make sure that this importer is installed on a computer that already has Visual Studio and/or TFS Team Explorer installed (" + exception.Message + ")", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            catch (TypeLoadException exception)
            {
                // The runtime coulnd't find referenced type in the assembly.
                MessageBox.Show("Error Connecting to MTM. You need to make sure that this importer is installed on a computer that already has Visual Studio and/or TFS Team Explorer installed (" + exception.Message + ")", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }