InfoLearner
InfoLearner

Reputation: 15598

How to Check who is calling the WCF Windows service

I have created a WCF service that is hosted using windows service.

The windows service is running under LocalSystem under services.msc

I only want to allow accept requests from my asp.net UI users who are part of dmain's user group? Eventually we will have multiple UIs and I want to not write security checks code in the UI.

How do I check who is making the call so I could do something like:

if (incomingUserGroup != "GroupRequired)
{
 throw NotAllowedException();
}

Upvotes: 1

Views: 257

Answers (1)

Darren Lewis
Darren Lewis

Reputation: 8488

You can inspect the security credentials of the calling user through the OperationContext. This will be subject to your having made the service available on an endpoint using a secured binding such as netTcpBinding or WSHttpBinding.

OperationContext.Current.ServiceSecurityContext.WindowsIdentity.Groups

Upvotes: 1

Related Questions