如果您添加端点行为以将名称从 WindowsIdentity 添加到 WCF 标头会怎样?这样(至少在我的情况下)身份更容易在管道的下游获得,但这足以满足您的“帐户名称”目的吗?
#region IDispatchMessageInspector Members
public object AfterReceiveRequest(
ref System.ServiceModel.Channels.Message request,
System.ServiceModel.IClientChannel channel,
System.ServiceModel.InstanceContext instanceContext)
{
if (ServiceSecurityContext.Current == null ||
ServiceSecurityContext.Current.WindowsIdentity == null)
return null;
WindowsUserName windowsUserName = new WindowsUserName();
request.Headers.Add(MessageHeader.CreateHeader(
windowsUserName.Name, windowsUserName.Namespace,
ServiceSecurityContext.Current.WindowsIdentity.Name));
return null;
}
public void BeforeSendReply(ref Message reply, object correlationState)
{
return;
}
#endregion
使用客户端证书时同样适用,但使用PrimaryIdentity
而不是WindowsIdentity
获取 BizTalk 方名称。不过,这与活动目录帐户没有直接联系。