I'm currently trying to figure out how to perform manual Windows authentication in our ASP.NET application. The problem is that we are running the OData service, and use FormsAuthentication to provide a common login mechanism and enable PUT and DELETE commands for OData, including form redirection.
However, for some clients, we integrated Windows authentication to provide seamless integration for our active directory users. The problem is that we want to be able to switch authentication methods without disrupting the Odata service, because we are dependent on it.
What we are trying to do is mimic the mechanics of Windows authentication using the IhttpModule. For now, we can turn the function on and off, and we get a call when the request is made. I do not know how to use the received information from the browser to perform authentication in the active directory:
This is the code we use to extract NTLM information from the current request:
/// <summary> /// <para>Determines whether the current <see cref="HttpRequest"/> is a NTML challenge.</para> /// </summary> /// <param name="request">The <see cref="HttpRequest"/> to evaluate.</param> /// <param name="header">The output header to authenticate.</param> /// <returns>True if the current <see cref="HttpRequest"/> is considered a NTML challenge.</returns> protected bool IsNtlmChallenge(HttpRequest request, out string header) { const string headerName = @"Authorization"; if (request.Headers.AllKeys.Contains(headerName)) { header = request.Headers[headerName]; return true; } header = string.Empty; return false; }
This allows us to extract the header from the request. Now I need to know how I authenticate with this in the active directory.
This is the logic we use to extract information:
Hope someone can provide the underder that I need.
coding-bunny
source share