IntranetZoneCredentialPolicy.ShouldSendCredential 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
Boolean 를 사용하여 WebRequest만든 리소스에 대한 요청과 함께 클라이언트의 자격 증명을 보낼지 여부를 나타내는 값을 반환합니다.
public:
virtual bool ShouldSendCredential(Uri ^ challengeUri, System::Net::WebRequest ^ request, System::Net::NetworkCredential ^ credential, System::Net::IAuthenticationModule ^ authModule);
public virtual bool ShouldSendCredential(Uri challengeUri, System.Net.WebRequest request, System.Net.NetworkCredential credential, System.Net.IAuthenticationModule authModule);
abstract member ShouldSendCredential : Uri * System.Net.WebRequest * System.Net.NetworkCredential * System.Net.IAuthenticationModule -> bool
override this.ShouldSendCredential : Uri * System.Net.WebRequest * System.Net.NetworkCredential * System.Net.IAuthenticationModule -> bool
Public Overridable Function ShouldSendCredential (challengeUri As Uri, request As WebRequest, credential As NetworkCredential, authModule As IAuthenticationModule) As Boolean
매개 변수
- request
- WebRequest
WebRequest 요청되는 리소스를 나타내는 값입니다.
- credential
- NetworkCredential
이 NetworkCredential 메서드가 반환 true되는 경우 요청과 함께 전송되는 값입니다.
- authModule
- IAuthenticationModule
IAuthenticationModule 인증이 필요한 경우 인증을 수행합니다.
반품
true요청된 리소스가 요청을 하는 클라이언트와 동일한 도메인에 있으면 이고, 그렇지 않으면 . false
구현
예제
다음 코드 예제에서는 기본 인증을 IntranetZoneCredentialPolicy 사용하여 HTTPS(Secure Hypertext Transfer Protocol)를 사용하는 요청에 대해 자격 증명을 보낼 수 있도록 파생하는 방법을 보여 줍니다. HTTPS 및 기본 인증을 사용하여 네트워크를 통해 전송되기 전에 사용자 암호가 암호화됩니다.
// The following class allows credentials to be sent if they are for requests for resources
// in the same domain, or if the request uses the HTTPSscheme and basic authentication is
// required.
public ref class HttpsBasicCredentialPolicy: public IntranetZoneCredentialPolicy
{
public:
HttpsBasicCredentialPolicy(){}
virtual bool ShouldSendCredential( Uri^ challengeUri, WebRequest^ request, NetworkCredential^ credential, IAuthenticationModule^ authModule ) override
{
Console::WriteLine( L"Checking custom credential policy for HTTPS and basic." );
bool answer = IntranetZoneCredentialPolicy::ShouldSendCredential( challengeUri, request, credential, authModule );
if ( answer )
{
Console::WriteLine( L"Sending credential for intranet resource." );
return answer;
}
// Determine whether the base implementation returned false for basic and HTTPS.
if ( request->RequestUri->Scheme == Uri::UriSchemeHttps && authModule->AuthenticationType->Equals( L"Basic" ) )
{
Console::WriteLine( L"Sending credential for HTTPS and basic." );
return true;
}
return false;
}
};
// The following class allows credentials to be sent if they are for requests for resources
// in the same domain, or if the request uses the HTTPSscheme and basic authentication is
// required.
public class HttpsBasicCredentialPolicy: IntranetZoneCredentialPolicy
{
public HttpsBasicCredentialPolicy()
{
}
public override bool ShouldSendCredential(Uri challengeUri,
WebRequest request,
NetworkCredential credential,
IAuthenticationModule authModule)
{
Console.WriteLine("Checking custom credential policy for HTTPS and basic.");
bool answer = base.ShouldSendCredential(challengeUri, request, credential, authModule);
if (answer )
{
Console.WriteLine("Sending credential for intranet resource.");
return answer;
}
// Determine whether the base implementation returned false for basic and HTTPS.
if (request.RequestUri.Scheme == Uri.UriSchemeHttps &&
authModule.AuthenticationType == "Basic")
{
Console.WriteLine("Sending credential for HTTPS and basic.");
return true;
}
return false;
}
}
설명
애플리케이션은 이 메서드를 직접 호출하지 않습니다. 서버로 인증을 IAuthenticationModule 수행하는 역할을 하는 사용자에 의해 호출됩니다. 이 메서드가 반환 false되면 서버에서 IAuthenticationModule 클라이언트를 인증하지 않습니다.
이 메서드는 자격 증명을 지정하거나 자격 증명을 지정하는 개체를 WebProxy 사용하는 요청에 대해서만 호출됩니다.