我知道您可以使用以下方法在 ASP.Net 应用中启用 NTLM 身份验证:
<authentication mode="Windows" />
但是 - 我需要在同一应用程序中处理表单、HTTP 和其他自定义身份验证,因此 ASP.Net 有限的内置支持没有用。
NTLM 握手应该相当简单:
Request - [unauthenticated - no user info passed]
Response - 401 Unauthorized
WWW-Authenticate: NTLM
Request - Authorization: NTLM <base64-encoded type-1-message>
Response - 401 Unauthorized
WWW-Authenticate: NTLM <base64-encoded type-2-message>
Request - Authorization: NTLM <base64-encoded type-3-message>
Server can now check username/password against LDAP from type-3 message
Response - 200 Ok [now authenticated & authorised]
因此,为了自己滚动,我需要解析 type-1 和 type-3 消息并生成 type-2 消息。
这些消息的结构是 well documented but fairly complex - 编写我自己的消息生成器和解析器似乎很乱。我认为读取和写入这些消息的方法应该已经在.Net 中,但我一直没能找到它们。
如何使用 .Net 构建和解析这些 NTLM 消息?
最佳答案
Cassini 支持 NTLM 身份验证,因此您可以使用源代码更轻松地创建一个解析 NTLM 授权消息的类。
关于asp.net - 在 ASP.Net 中编写自定义 NTLM 质询/响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4723062/