我有一个WCF Web服务,其操作如下:
public void CreateWorkItem(string title, NetworkCredential credential)
{
// Call a method that requires credential to work.
// I want to use the credential of the user not the server's.
}
但不允许使用NetworkCredential
作为参数。
如何将客户端的本地凭据传递给Web服务,以便它可以使用它们?
答案 0 :(得分:0)
将用户的凭据作为参数传递的重点是什么?我认为你可以通过ServiceSecurityContext得到它,其中:
表示远程方的安全上下文。在客户端上,表示服务标识,服务上的表示客户端标识。
e.g。
// Write the primary identity and Windows identity. The primary identity is derived from
// the credentials used to authenticate the user. The Windows identity may be a null string.
sw.WriteLine("PrimaryIdentity: {0}", ServiceSecurityContext.Current.PrimaryIdentity.Name);
sw.WriteLine("WindowsIdentity: {0}", ServiceSecurityContext.Current.WindowsIdentity.Name);