Example #1
0
        void AuthenticateUser(Uri uri, string authenticationType)
        {
            DiscoveryNetworkCredential credential = (DiscoveryNetworkCredential)credentialCache.GetCredential(uri, authenticationType);

            if (credential != null)
            {
                StartDiscovery(uri, credential);
            }
            else
            {
                using (UserCredentialsDialog credentialsForm = new UserCredentialsDialog(uri.ToString(), authenticationType)) {
                    if (DialogResult.OK == credentialsForm.ShowDialog())
                    {
                        StartDiscovery(uri, credentialsForm.Credential);
                    }
                }
            }
        }
		DiscoveryClientProtocol DiscoverWebServices(string url)
		{
			WebServiceDiscoveryClientProtocol protocol = new WebServiceDiscoveryClientProtocol();
			NetworkCredential credential = CredentialCache.DefaultNetworkCredentials;
			bool retry = true;
			while (retry) {
				try {
					protocol.Credentials = credential;
					protocol.DiscoverAny(url);
					protocol.ResolveOneLevel();
					return protocol;
				} catch (WebException ex) {
					if (protocol.IsAuthenticationRequired) {
						using (UserCredentialsDialog dialog = new UserCredentialsDialog(url, protocol.GetAuthenticationHeader().AuthenticationType)) {
							if (dialog.ShowDialog(WorkbenchSingleton.MainWin32Window) == DialogResult.OK) {
								credential = dialog.Credential;
							} else {
								retry = false;
							}
						}
					} else {
						throw ex;
					}
				}
			}
			return null;
		}
 void AuthenticateUser(Uri uri, string authenticationType)
 {
     DiscoveryNetworkCredential credential = (DiscoveryNetworkCredential)credentialCache.GetCredential(uri, authenticationType);
     if (credential != null) {
         StartDiscovery(uri, credential);
     } else {
         using (UserCredentialsDialog credentialsForm = new UserCredentialsDialog(uri.ToString(), authenticationType)) {
             if (DialogResult.OK == credentialsForm.ShowDialog(SD.WinForms.MainWin32Window)) {
                 StartDiscovery(uri, credentialsForm.Credential);
             }
         }
     }
 }