使用WCF在App.config中使用Windows角色身份验证 [英] Using Windows Role authentication in the App.config with WCF

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

问题描述

我正在使用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?

谢谢

推荐答案

如果我很了解,您想在运行时选择角色.可以通过权限来完成在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();
    ...

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

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