tags:

views:

41

answers:

1

Hi,

I wrote a huge 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>

Thanks a lot my friends

+1  A: 

Try this:

bool hasAccess = HttpContext.Current.User.IsInRole("Administrators");
Rubens Farias
Aaah, a clean and simple answer. Always nice to read :)Sorry for not figuring this out on my own
WtFudgE