WCF获得用户组

时间:2010-02-09 09:30:18

标签: c# wcf

我写了一个巨大的应用程序,它使用WCF服务来执行诸如从数据库读取以及能够使用集成安全性之类的事情。

Atm我使用以下代码获取当前登录的用户名:

string userName = HttpContext.Current.User.Identity.Name;

但是我希望能够获取用户所在的活动目录组,因为这样可以使它更容易,而不是总是添加新用户。任何人都知道如何以干净简单的方式做到这一点?

不知道这是否相关,但我的端点配置为:

<service behaviorConfiguration="ZNA.Integratie.KopMon.Web.LoginServiceBehavior"
name="ZNA.Integratie.KopMon.Web.LoginService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="Security" contract="ZNA.Integratie.KopMon.Web.LoginService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

<behavior name="ZNA.Integratie.KopMon.Web.LoginServiceBehavior">
 <serviceMetadata httpGetEnabled="true" />
 <serviceDebug includeExceptionDetailInFaults="false" />
</behavior>

<binding name="Security">
  <security mode="TransportCredentialOnly">
    <transport clientCredentialType="Windows" />
  </security>
</binding>

1 个答案:

答案 0 :(得分:1)

试试这个:

bool hasAccess = HttpContext.Current.User.IsInRole("Administrators");
相关问题