将 App.config 中的 Windows 角色身份验证与 WCF 结合使用 [英] Using Windows Role authentication in the App.config with WCF

查看:18
本文介绍了将 App.config 中的 Windows 角色身份验证与 WCF 结合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 WCF 服务和 net.tcp 端点,并且 serviceAuthentication 的主体 PermissionMode 设置为 UseWindowsGroups.

I am using a WCF service and a net.tcp endpoint with serviceAuthentication's principal PermissionMode set to UseWindowsGroups.

目前在服务的实现中,我使用 PrincipalPermission 属性来设置每个方法的角色要求.

Currently in the implementation of the service i am using the PrincipalPermission attribute to set the role requirements for each method.

        [PrincipalPermission(SecurityAction.Demand, Role = "Administrators")]
        [OperationBehavior(Impersonation = ImpersonationOption.Required)]
        public string method1()

我正在尝试做几乎完全相同的事情,除了在 app.config 中设置角色的配置.有什么办法可以做到这一点并且仍然使用 Windows 组身份验证?

I am trying to do pretty much the same exact thing, except have the configuration for the role set in the app.config. Is there any way to do this and still be using windows groups authentication?

谢谢

推荐答案

如果我理解你想在运行时选择角色.这可以通过 permission 需求来完成在 WCF 操作中.例如

If I understood well you want to select the role at runtime. This can be done with a permission demand within the WCF operation. E.g.

public string method1()
{
    PrincipalPermission p = new PrincipalPermission(null, "Administrators");
    p.Demand();
    ...

这篇关于将 App.config 中的 Windows 角色身份验证与 WCF 结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆