代码之家  ›  专栏  ›  技术社区  ›  ng5000

如何在WCF服务中列出请求用户的角色?

  •  2
  • ng5000  · 技术社区  · 16 年前

    // Could use declarative security here, i.e. using PrincipalPermission attribute
    public string MyService()
    {
        // Would like some code that does something like:
        foreach( Role role in CurrentUser.Roles )
        {
        }
    }
    

    谢谢

    2 回复  |  直到 16 年前
        1
  •  2
  •   ng5000    16 年前

    在处理Windows组时,您可以使用以下代码:

    foreach (IdentityReference idRef in WindowsIdentity.GetCurrent().Groups)
    {
        Console.WriteLine(idRef.Translate(typeof(NTAccount)).Value);
    }
    
        2
  •  2
  •   Paul Lalonde    16 年前

    推荐文章