![](/img/trans.png)
[英]Share data between Windows Service and Cassini-dev running in the same process
[英]SecurityIdentifiers in Cassini-dev's NTLM authentication
在Cassini-dev的NTLM身份验证类中的这段代码中,对SECUR32.DLL(通过Interop )进行了调用,以对HTTP请求的Authorization
标头中的base64编码数据进行身份验证。 这很有道理,当AcceptSecurityContext()和QuerySecurityContextToken()都返回0
,客户端已被授权。 最后,安全上下文令牌具有从中提取的SecurityIdentifier
( _sid变量)。 (有关常见的安全ID的一些知识 )
这是NtlmAuth类的相关部分
int num = Interop.AcceptSecurityContext(ref _credentialsHandle, zero,
ref _inputBufferDesc, 20,
0, ref _securityContext, ref _outputBufferDesc,
ref _securityContextAttributes, ref _timestamp);
if (num == 0x90312)
{
securityContextAcquired = true;
_blob = Convert.ToBase64String(inArray, 0, (int) _outputBuffer.cbBuffer);
}
else
{
if (num != 0)
{
return false;
}
IntPtr phToken = IntPtr.Zero;
if (Interop.QuerySecurityContextToken(ref _securityContext, ref phToken) != 0)
{
return false;
}
try
{
using (WindowsIdentity identity = new WindowsIdentity(phToken))
{
_sid = identity.User;
}
}
finally
{
Interop.CloseHandle(phToken);
}
_completed = true;
在“ 请求类”中 ,在使用TryNtlmAuthenticate()
方法中,成功完成NTLM身份验证的3个步骤之后,在返回最终的403或完成请求之前,将进行一次最终检查:
if (_host.GetProcessSid() != auth.SID)
{
_connection.WriteErrorAndClose(0x193);
return false;
}
在这里, _host.GetProcessSid()是Cassini进程(me)的所有者的SecurityIndentifier
,而auth.SID是已通过身份验证的用户的SecurityIdentifier
性ID (来自上面NtlmAuth类的_sid)。 如果这两个SID不相同,则返回403并停止身份验证,否则将请求提供给浏览器。
我的问题是:
更新:似乎在cassinidev论坛上有人提出了一个补丁,该补丁可以在2010年删除此SID检查 (补丁#6604),但仍在评估中。
这不是一个答案,但我只是注意到一个类似的问题,只是一个略有不同的表现形式:当托管在Windows服务中并且Cassini-dev配置为使用Windows身份验证时,HttpContext.Current.User是服务正在运行的帐户在下面,而不是发出请求的用户。
在我看来,这似乎是卡西尼开发版中的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.