Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have wss 3.0 with auth type Integrated Windows Authentication/Kerberos. I want to make custom login form. I developed below codes. After executed I got error: The remote server returned an error: (401) Unauthorized. Why?

string url = @"http://10.6.11.23/_layouts/Authenticate.aspx?Source=%2FEnterprise%20Portal%2Fdefault%2Easpx%3Fredirected%3D1%26WCMP%3DMIG";

    WebRequest request = WebRequest.Create(url);

    request.Credentials = GetCredential();
    request.UseDefaultCredentials = false;
    request.PreAuthenticate = true;
    request.Method = "POST";
    request.ContentLength = 0;
    request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");

private CredentialCache GetCredential()
{
    string url = @"https://10.6.11.23/";
    CredentialCache credentialCache = new CredentialCache();
    string authType = "IntegratedWindowsAuthentication";

    credentialCache.Add(new System.Uri(url), authType, new NetworkCredential("jacek", "pass123", "domainName"));
    return credentialCache;
}
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.