private void btnCheckConnectivity_Click(object sender, EventArgs e)
        {
            this.Text = TITLE_VERIFYING;//temporary chnage due to cnnection
            lblWarning.Visible = false;
            lblWarning.ForeColor = Color.Red;

            if (txtUrl.Text.Trim().Equals(""))
            {
                lblWarning.Text = "ERROR: Web Site URL cannot be blank. Please enter valid web site URL";
                lblWarning.Visible = true;
            }
            else if (cbUseWindowsSessionCreds.Checked != true)
            {
                //check for the default credentails
                if (txtUserName.Text.Trim().Equals(""))
                {
                    lblWarning.Text = "ERROR: User name cannot be blank. Please enter valid user name";
                    lblWarning.Visible = true;
                }
                else if (txtPassword.Text.Trim().Equals(""))
                {
                    lblWarning.Text = "ERROR: Password cannot be blank. Please enter valid password";
                    lblWarning.Visible = true;
                }
            }//end: else

            String webServiceEndPointURL = "";
            if (lblWarning.Visible == false)
            {

                if (txtUrl.Text.EndsWith("/"))
                {
                    webServiceEndPointURL = txtUrl.Text + "_vti_bin/GSSiteDiscovery.asmx";
                }
                else
                {
                    webServiceEndPointURL = txtUrl.Text + "/_vti_bin/GSSiteDiscovery.asmx";
                }
                try
                {
                    GSPSiteDiscoveryWS.SiteDiscovery customser = new GSPSiteDiscoveryWS.SiteDiscovery();
                    customser.Url = webServiceEndPointURL;

                    //Check: if the user is using the default credentials
                    if (cbUseWindowsSessionCreds.Checked == true)
                    {
                        customser.Credentials = CredentialCache.DefaultCredentials;
                    }
                    else
                    {
                        customser.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text, txtDomain.Text);
                    }

                    String val = customser.CheckConnectivity();
                    if (!val.ToLower().Equals("success"))
                    {
                        lblWarning.Text = "ERROR: Connection to Google Services for SharePoint failed";
                        lblWarning.Visible = true;
                    }
                }
                catch (Exception)
                {
                    lblWarning.Text = "ERROR: Connection to Google Services for SharePoint failed";
                    lblWarning.Visible = true;
                }

                //case of bulkWS
                if (lblWarning.Visible == false)
                {
                    if (txtUrl.Text.EndsWith("/"))
                    {
                        webServiceEndPointURL = txtUrl.Text + "_vti_bin/GSBulkAuthorization.asmx";
                    }
                    else
                    {
                        webServiceEndPointURL = txtUrl.Text + "/_vti_bin/GSBulkAuthorization.asmx";
                    }
                    try
                    {
                        GSPBulkWS.BulkAuthorization bulkWs = new GSPBulkWS.BulkAuthorization();
                        bulkWs.Url = webServiceEndPointURL;
                        //Check: if the user is using the default credentials
                        if (cbUseWindowsSessionCreds.Checked == true)
                        {
                            bulkWs.Credentials = CredentialCache.DefaultCredentials;
                        }
                        else
                        {
                            bulkWs.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text, txtDomain.Text);
                        }

                        //bulkWs.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text, txtDomain.Text);
                        String val = bulkWs.CheckConnectivity();
                        if (!val.ToLower().Equals("success"))
                        {
                            lblWarning.Text = "ERROR: Connection to Google Services for SharePoint failed";
                            lblWarning.Visible = true;
                        }
                    }
                    catch (Exception ee)
                    {
                        //lblWarning.Text = "ERROR: Connection to Google Services for SharePoint failed";
                        lblWarning.Text = ee.Message;
                        lblWarning.Visible = true;
                    }
                }

                //case of ACL WS
                if (lblWarning.Visible == false)
                {
                    if (txtUrl.Text.EndsWith("/"))
                    {
                        webServiceEndPointURL = txtUrl.Text + "_vti_bin/GssAcl.asmx";
                    }
                    else
                    {
                        webServiceEndPointURL = txtUrl.Text + "/_vti_bin/GssAcl.asmx";
                    }
                    try
                    {

                        GSPAclWS.GssAclMonitor aclWS = new GSPAclWS.GssAclMonitor();
                        aclWS.Url = webServiceEndPointURL;

                        //Check: if the user is using the default credentials
                        if (cbUseWindowsSessionCreds.Checked == true)
                        {
                            aclWS.Credentials = CredentialCache.DefaultCredentials;
                        }
                        else
                        {
                            aclWS.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text, txtDomain.Text);
                        }

                        String val = aclWS.CheckConnectivity();
                        if (!val.ToLower().Equals("success"))
                        {
                            lblWarning.Text = "ERROR: Connection to Google Services for SharePoint failed";
                            lblWarning.Visible = true;
                        }
                    }
                    catch (Exception ee)
                    {
                        lblWarning.Text = ee.Message;
                        lblWarning.Visible = true;
                    }
                }

            }

            if (lblWarning.Visible == false)
            {
                //check if the operation completed successfully
                lblWarning.ForeColor = Color.Green;
                lblWarning.Text = "Connection to Google Services for SharePoint succeeded";
                lblWarning.Visible = true;
            }

            this.Text = TITLE;//restore the original title
        }
コード例 #2
0
        private void btnCheckConnectivity_Click(object sender, EventArgs e)
        {
            this.Text            = TITLE_VERIFYING;//temporary chnage due to cnnection
            lblWarning.Visible   = false;
            lblWarning.ForeColor = Color.Red;

            if (txtUrl.Text.Trim().Equals(""))
            {
                lblWarning.Text    = "ERROR: Web Site URL cannot be blank. Please enter valid web site URL";
                lblWarning.Visible = true;
            }
            else if (cbUseWindowsSessionCreds.Checked != true)
            {
                //check for the default credentails
                if (txtUserName.Text.Trim().Equals(""))
                {
                    lblWarning.Text    = "ERROR: User name cannot be blank. Please enter valid user name";
                    lblWarning.Visible = true;
                }
                else if (txtPassword.Text.Trim().Equals(""))
                {
                    lblWarning.Text    = "ERROR: Password cannot be blank. Please enter valid password";
                    lblWarning.Visible = true;
                }
            }//end: else

            String webServiceEndPointURL = "";

            if (lblWarning.Visible == false)
            {
                if (txtUrl.Text.EndsWith("/"))
                {
                    webServiceEndPointURL = txtUrl.Text + "_vti_bin/GSSiteDiscovery.asmx";
                }
                else
                {
                    webServiceEndPointURL = txtUrl.Text + "/_vti_bin/GSSiteDiscovery.asmx";
                }
                try
                {
                    GSPSiteDiscoveryWS.SiteDiscovery customser = new GSPSiteDiscoveryWS.SiteDiscovery();
                    customser.Url = webServiceEndPointURL;

                    //Check: if the user is using the default credentials
                    if (cbUseWindowsSessionCreds.Checked == true)
                    {
                        customser.Credentials = CredentialCache.DefaultCredentials;
                    }
                    else
                    {
                        customser.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text, txtDomain.Text);
                    }

                    String val = customser.CheckConnectivity();
                    if (!val.ToLower().Equals("success"))
                    {
                        lblWarning.Text    = "ERROR: Connection to Google Services for SharePoint failed";
                        lblWarning.Visible = true;
                    }
                }
                catch (Exception)
                {
                    lblWarning.Text    = "ERROR: Connection to Google Services for SharePoint failed";
                    lblWarning.Visible = true;
                }

                //case of bulkWS
                if (lblWarning.Visible == false)
                {
                    if (txtUrl.Text.EndsWith("/"))
                    {
                        webServiceEndPointURL = txtUrl.Text + "_vti_bin/GSBulkAuthorization.asmx";
                    }
                    else
                    {
                        webServiceEndPointURL = txtUrl.Text + "/_vti_bin/GSBulkAuthorization.asmx";
                    }
                    try
                    {
                        GSPBulkWS.BulkAuthorization bulkWs = new GSPBulkWS.BulkAuthorization();
                        bulkWs.Url = webServiceEndPointURL;
                        //Check: if the user is using the default credentials
                        if (cbUseWindowsSessionCreds.Checked == true)
                        {
                            bulkWs.Credentials = CredentialCache.DefaultCredentials;
                        }
                        else
                        {
                            bulkWs.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text, txtDomain.Text);
                        }

                        //bulkWs.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text, txtDomain.Text);
                        String val = bulkWs.CheckConnectivity();
                        if (!val.ToLower().Equals("success"))
                        {
                            lblWarning.Text    = "ERROR: Connection to Google Services for SharePoint failed";
                            lblWarning.Visible = true;
                        }
                    }
                    catch (Exception ee)
                    {
                        //lblWarning.Text = "ERROR: Connection to Google Services for SharePoint failed";
                        lblWarning.Text    = ee.Message;
                        lblWarning.Visible = true;
                    }
                }

                //case of ACL WS
                if (lblWarning.Visible == false)
                {
                    if (txtUrl.Text.EndsWith("/"))
                    {
                        webServiceEndPointURL = txtUrl.Text + "_vti_bin/GssAcl.asmx";
                    }
                    else
                    {
                        webServiceEndPointURL = txtUrl.Text + "/_vti_bin/GssAcl.asmx";
                    }
                    try
                    {
                        GSPAclWS.GssAclMonitor aclWS = new GSPAclWS.GssAclMonitor();
                        aclWS.Url = webServiceEndPointURL;

                        //Check: if the user is using the default credentials
                        if (cbUseWindowsSessionCreds.Checked == true)
                        {
                            aclWS.Credentials = CredentialCache.DefaultCredentials;
                        }
                        else
                        {
                            aclWS.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text, txtDomain.Text);
                        }

                        String val = aclWS.CheckConnectivity();
                        if (!val.ToLower().Equals("success"))
                        {
                            lblWarning.Text    = "ERROR: Connection to Google Services for SharePoint failed";
                            lblWarning.Visible = true;
                        }
                    }
                    catch (Exception ee)
                    {
                        lblWarning.Text    = ee.Message;
                        lblWarning.Visible = true;
                    }
                }
            }

            if (lblWarning.Visible == false)
            {
                //check if the operation completed successfully
                lblWarning.ForeColor = Color.Green;
                lblWarning.Text      = "Connection to Google Services for SharePoint succeeded";
                lblWarning.Visible   = true;
            }

            this.Text = TITLE;//restore the original title
        }