【发布时间】:2015-02-04 06:09:06
【问题描述】:
在敲了一天的头之后,我正在寻求帮助。我有一个 Web 窗体应用程序,WCF 服务托管在同一台机器上。 WCF 服务具有具有某种自定义权限的方法(例如,只有“admin”可以为用户设置密码)。
Web 表单应用程序使用表单身份验证,因此我拥有 HttpContext.Current.User 以及此使用的所有角色。所以我使用AuthCookie 来通过HttpRequestMessageProperty 传递对象并像这样读取它:
HttpRequestMessageProperty property =
OperationContext.Current.IncomingMessageProperties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
basicHttpBinding 工作正常。但是后来我需要实现 net.tcp 协议,所以 HttpRequestMessageProperty 不再起作用了。我尝试通过MessageHeader 添加它,但这也不起作用。
OperationContext.Current.IncomingMessageProperties没有我的标题...
那么如何将用户角色列表传递给我的 WCF?我正在使用这样的 Windows 安全性,但我需要从 HttpContext.Current.User 传递角色:
<netTcpBinding>
<binding transactionFlow="True">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
【问题讨论】:
标签: asp.net wcf soap nettcpbinding