我有一个基于WSE3.0的web服务在IIS6.0下运行在Windows 2003中。我希望web服务进程模拟发送web服务请求的客户端用户,但是服务不是模拟客户端。
web应用程序有自己的应用程序池,该应用程序池目前设置为在网络服务标识下运行。已为Active Directory中的委托启用了Windows Server 2003计算机帐户(至少根据我的IT人员)。WSE策略(在wse3policyCache.config中)如下所示:
<policy name="GeneratedServicesPolicy">
<kerberosSecurity establishSecurityContext="false" renewExpiredSecurityContext="true" requireSignatureConfirmation="false" messageProtectionOrder="SignBeforeEncrypt" requireDerivedKeys="true" ttlInSeconds="300">
<protection>
<request signatureOptions="IncludeAddressing, IncludeTimestamp, IncludeSoapBody" encryptBody="false" />
<response signatureOptions="IncludeAddressing, IncludeTimestamp, IncludeSoapBody" encryptBody="false" />
<fault signatureOptions="IncludeAddressing, IncludeTimestamp, IncludeSoapBody" encryptBody="false" />
</protection>
</kerberosSecurity>
<requireActionHeader />
</policy>该服务的web.config中有以下条目(除其他外):
<identity impersonate="false"/>
<authentication mode="Windows"/>为应用程序启用了匿名访问(这是必需的,因为服务不使用传输级别的安全性,消息层是)。该机器帐户注册了以下SPN:
HOST/RD360-2
HOST/rd360-2.mycompany.com客户端的wse3policyCache.config中有以下内容:
<policy name="KerbClient">
<kerberosSecurity establishSecurityContext="false" renewExpiredSecurityContext="true" requireSignatureConfirmation="false" messageProtectionOrder="SignBeforeEncrypt" requireDerivedKeys="true" ttlInSeconds="300">
<token>
<kerberos targetPrincipal="HOST/rd360-2.mycompany.com" impersonationLevel="Impersonation" />
</token>
<protection>
<request signatureOptions="IncludeAddressing, IncludeTimestamp, IncludeSoapBody" encryptBody="false" />
<response signatureOptions="IncludeAddressing, IncludeTimestamp, IncludeSoapBody" encryptBody="false" />
<fault signatureOptions="IncludeAddressing, IncludeTimestamp, IncludeSoapBody" encryptBody="false" />
</protection>
</kerberosSecurity>
<requireActionHeader />
</policy>客户端代码如下所示:
static void Main(string[] args)
{
AddFloatsWSWse client = new AddFloatsWSWse();
client.SetPolicy("KerbClient");
double result = client.AddFloats(2.3, 3.2);
Console.WriteLine("Result was: '" + result + "'");
}不过,该服务并不是在冒充我的客户身份。我在服务中使用log4net,当我要求它将%username打印到ASP.NET跟踪日志中时,总是NT AUTHORITY\NETWORK SERVICE而不是客户端用户id。我做错什么了吗?有什么地方我可以看看WSE是否正在尝试执行模拟和失败?我确实在我的事件日志中看到了以下条目(MYDOMAIN和MYUSER在这里是模糊的):
Event Type: Success Audit
Event Source: Security
Event Category: Privilege Use
Event ID: 576
Date: 12/9/2009
Time: 11:07:16 AM
User: MYDOMAIN\MYUSER
Computer: RD360-2
Description:
Special privileges assigned to new logon:
User Name: MYUSER
Domain: MYDOMAIN
Logon ID: (0x0,0x4B410AE)
Privileges: SeSecurityPrivilege
SeBackupPrivilege
SeRestorePrivilege
SeTakeOwnershipPrivilege
SeDebugPrivilege
SeSystemEnvironmentPrivilege
SeLoadDriverPrivilege
SeImpersonatePrivilege
----------------------------------------------------------------------------------
Event Type: Success Audit
Event Source: Security
Event Category: Logon/Logoff
Event ID: 540
Date: 12/9/2009
Time: 11:07:16 AM
User: MYDOMAIN\MYUSER
Computer: RD360-2
Description:
Successful Network Logon:
User Name: MYUSER
Domain: MYDOMAIN
Logon ID: (0x0,0x4B410AE)
Logon Type: 3
Logon Process: Kerberos
Authentication Package: Kerberos
Workstation Name:
Logon GUID: {OBFUSCATED}
Caller User Name: -
Caller Domain: -
Caller Logon ID: -
Caller Process ID: -
Transited Services: -
Source Network Address: -
Source Port: -在我的WSE跟踪文件中,我确实看到:
<processingStep description="Entering SOAP filter Microsoft.Web.Services3.Design.RequireSoapHeaderAssertion+RequireSoapHeaderFilter" />
<processingStep description="Exited SOAP filter Microsoft.Web.Services3.Design.RequireSoapHeaderAssertion+RequireSoapHeaderFilter" />
<processingStep description="Entering SOAP filter Microsoft.Web.Services3.Design.KerberosAssertion+ServiceInputFilter" />
<processingStep description="Exited SOAP filter Microsoft.Web.Services3.Design.KerberosAssertion+ServiceInputFilter" />因此,至少我知道Kerberos扩展正在处理我的Kerberos头。
编辑:然后使用专用客户端通信库SSPI/IWA调用另一台服务器(让我们将第三台服务器称为foo服务器)。我希望它在第二次调用foo服务器时使用客户端的身份。这意味着这个客户端通信库使用foo服务器的SPN和一个不同的服务调用AcquireCredentialsHandle和InitializeSecurityContext。在这种情况下,foo服务器实际上与WSE服务运行在同一台机器上(因此它使用的是SPN mycompany/rd260-2)。因为第二个跳到同一台机器上,我希望它使用NTLM,但它仍然应该模拟我的web服务客户端的用户身份,不是吗?在foo服务器的日志中,我看到它接受连接,使用提供的IWA安全上下文,并告诉我,基于这个安全上下文,连接的用户是rd36-2$,这是机器帐户,因为web服务在IIS中运行在网络服务标识下(而后者又与机器帐户相关联)。在foo服务器的日志中,在接收到IWA安全上下文之后,我最终希望看到提交web服务请求的用户的身份。将foo服务器移动到另一台计算机以查看这是否与此有关是否有用吗?
发布于 2009-12-12 16:21:43
与WSE 3一起使用的Kerberos令牌是一种消息级安全机制,只对客户端进行身份验证。实际上,它不会像IWA那样更改安全上下文,因此您不会注意到跟踪日志中有任何不同之处。为了真正模拟客户端,您必须:
<kerberos>元素上启用impersonationLevel="Impersonation" (您已经做过了);WindowsImpersonationContext。示例:
WindowsIdentity identity =
(WindowsIdentity)RequestSoapContext.Current.IdentityToken.Identity;
WindowsImpersonationContext impersonationContext = null;
try
{
impersonationContext = identity.Impersonate();
// Perform your work here
// ...
}
finally
{
if (impersonationContext != null)
{
impersonationContext.Undo();
}
}发布于 2009-12-12 17:40:58
就我所能理解的情况而言,当您试图跳第二跳时,Kerberos票就被丢弃了。在双跳场景中,Kerberos票证将在第二跳时丢弃。
在此之后,您的身份验证将失败,不会切换到NTLM。
https://stackoverflow.com/questions/1874998
复制相似问题