private static bool ChallengeIWA(IdentityManager.CredentialRequestInfos credentialRequestInfos,
Action<IdentityManager.Credential, Exception> callback)
{
if (credentialRequestInfos.AuthenticationType == IdentityManager.AuthenticationType.NetworkCredential &&
credentialRequestInfos.ResponseHeaders != null && CredentialCache.DefaultCredentials != null)
{
// test that we didn't already try the IWA authentication
if (TryDone(credentialRequestInfos.Url))
return false;
// get the WWW-Authenticate header
string header = credentialRequestInfos.ResponseHeaders.Get("WWW-Authenticate");
// if the header contains NTLM the server is using Integrated Windows
// Authentication (IWA), so try the current user's credentials
if (!string.IsNullOrEmpty(header) && header.Contains("NTLM")) // IWA
{
var credential = new IdentityManager.Credential
{
Url = credentialRequestInfos.Url,
Credentials = CredentialCache.DefaultCredentials
};
AddTry(credentialRequestInfos.Url);
callback(credential, null);
return true;
}
}
return false;
}