views:

805

answers:

2

Hello,

I have a client/server project, communicating with WCF (Named Pipes for now, but that can change - but I cannot use IIS). This project is integrated with Active Directory.

This program is designed to give users permissions that normally don't have permissions, by acting as a sort of proxy. The user uses the client to "request" a task to be performed. The server then performs the task for the client, as long as certain criteria are met.

One of these criteria is that the user is allowed to request this task. I need a way for my WCF service to guarantee the identity of the user, compare it to a database, and either perform the task, or deny the task.

How would I use Windows Authentication to guarantee 100% that the user is who they say they are?

Thanks in advance,

Mike

A: 

The only allowed type of authentication for Named Pipes is Windows Authentication (scroll down to netNamedPipeBinding). You can do the impersonation declareatively for example ...

[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public string GetData(int value)
{
  return string.Format("Hi, {0}, you have entered: {1}",
                           WindowsIdentity.GetCurrent().Name, value);
}

Once you have the identity, you know that Windows has properly authenticated this user and you can check that identity against what you have in your DB.

JP Alioto
Is the impersonation code required?I actually need to perform the task as a completely different user than the one requested. Just need to check their credentials against my database before continuing. Would this do that?
Mike Christiansen
You only need the impersonation to get the identity of the caller. If you get the current Windows Identity without impersonating, you will get the identity of the account under which the service is running. You only need to check, get the name and return the name from your method. You don't have to do the work in the method that impersonates the caller (in fact, that's what you don't want to do).
JP Alioto
A: 

You can create a custom ServiceAuthorizationManager and implement the validation against your user db in CheckAccessCore.

See How to: Create a Custom Authorization Manager for a Service.

Remus Rusanu