System.Net.AuthenticationManager.Authenticate C# (CSharp) Method

Authenticate() public static method

public static Authenticate ( string challenge, System request, ICredentials credentials ) : Authorization
challenge string
request System
credentials ICredentials
return Authorization
        public static Authorization Authenticate(string challenge, System.Net.WebRequest request, ICredentials credentials) { throw null; }
        public static Authorization PreAuthenticate(System.Net.WebRequest request, ICredentials credentials) { throw null; }

Usage Example

示例#1
0
		bool CheckAuthorization (WebResponse response, HttpStatusCode code)
		{
			authCompleted = false;
			if (code == HttpStatusCode.Unauthorized && credentials == null)
				return false;

			bool isProxy = (code == HttpStatusCode.ProxyAuthenticationRequired);
			if (isProxy && (proxy == null || proxy.Credentials == null))
				return false;

			string [] authHeaders = response.Headers.GetValues ( (isProxy) ? "Proxy-Authenticate" : "WWW-Authenticate");
			if (authHeaders == null || authHeaders.Length == 0)
				return false;

			ICredentials creds = (!isProxy) ? credentials : proxy.Credentials;
			Authorization auth = null;
			foreach (string authHeader in authHeaders) {
				auth = AuthenticationManager.Authenticate (authHeader, this, creds);
				if (auth != null)
					break;
			}
			if (auth == null)
				return false;
			webHeaders [(isProxy) ? "Proxy-Authorization" : "Authorization"] = auth.Message;
			authCompleted = auth.Complete;
			bool is_ntlm = (auth.Module.AuthenticationType == "NTLM");
			if (is_ntlm)
				ntlm_auth_state = (NtlmAuthState)((int) ntlm_auth_state + 1);
			return true;
		}
All Usage Examples Of System.Net.AuthenticationManager::Authenticate