开发者

WCF get Group of a User

I wrote a hug开发者_如何转开发e application which uses WCF services to do things like read from databases and also to be able to use integrated security.

Atm I use the following code to get the current logged on user name:

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

However I want to be able to get the active directory groups the user is in, because this would make it a lot easier instead of always adding new users. Anyone know how to do this in a clean and simple way?

Don't know if this is relevant, but my endpoint is configured as:

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


Try this:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜