2010-02-09 55 views
1

我寫了一個巨大的應用程序,它使用WCF服務來執行諸如從數據庫讀取以及能夠使用集成安全性等功能。WCF獲取用戶組

大氣壓我用下面的代碼來獲取用戶名當前登錄:

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

不過,我希望能夠得到Active Directory組的用戶是的,因爲這將使得很多更容易,而不是總是添加新用戶。任何人都知道如何以乾淨和簡單的方式做到這一點?

不知道這是否是相關的,但我的端點配置爲:

<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> 
+0

爲什麼你需要的羣體用戶是哪一個成員?如果是出於授權目的,更好的模型就是詢問他或她是否是特定團體/角色的成員。 – 2010-02-09 09:35:26

回答

1

試試這個:

bool hasAccess = HttpContext.Current.User.IsInRole("Administrators"); 
+0

Aaah,乾淨簡單的答案。總是很高興閱讀:) 對不起,我沒有想到這一點 – WtFudgE 2010-02-09 10:00:15