DESIGNING .NET 4

WINDOWS APPLICATIONS:

SECURITY IMPLEMENTATION

- IMPERSONATION

AND DELEGATION

using (ServiceSecurityContext.Current.WindowsIdentity.Impersonate())

{

// Access resources with the user's credentials.

return string.Format("hello, {0}",

WindowsIdentity.GetCurrent().Name);

}

[OperationBehavior(Impersonation = ImpersonationOption.Required)]

public void MyMethod(string input)

{

// TODO: Do work as user.

}

[OperationBehavior]

public void DoWorkAsUser(string input)

{

WindowsIdentity userContext = ServiceSecurityContext.Current.WindowsIdentity;

if (userContext == null)

{

throw new InvalidOperationException(

"The caller cannot be mapped to a WindowsIdentity.");

}

using (userContext.Impersonate())

{

// TODO: Do work as the user.

}

}

Trust This Computer For Delegation

To Specified Services Only

Impersonation

and Delegation

Application Developer

Responsible For