I'm writing web-application authenticating user using NTLM protocol.
I have successfully get password's NT and LM hashes from client. How I can validate them against Active Directory to ensure that password is correct.
I'm using C#, but I think it will be possible for me to call native library as well.
EDIT: I don't see reason for down-votes. NTLM(v2) protocol is outdated so it's really hard to find relative information on how to handle it. Especially from within such a modern language as C#.
But I have found two possible approaches:
- use of Windows' native SSPI calls (not recommended by Microsoft), but it's possible with proper wrapping. Lucky, there is an example: http://pinvoke.net/default.aspx/secur32/InitializeSecurityContext.html This approach seems to be working. I was able to verify account. But some questions remain, still. Such as transferring information about server's security context between clients' HTTP requests, call to unsafe code and impossibility to perform such operations on other systems.
- Trying unwrap calls done via
System.Net.Security.NegotiateStream
. The idea is nice, but no clue how to achieve this.