Edit

Share via


ImpersonationOption Enum

Definition

Specifies the impersonation behavior for a service operation on a service instance.

C#
public enum ImpersonationOption
Inheritance
ImpersonationOption

Fields

Name Value Description
NotAllowed 0

Impersonation is not performed. If ImpersonateCallerForAllOperations is equal to true, a validation exception occurs at service startup time.

Allowed 1

Impersonation is performed if credentials are available and ImpersonateCallerForAllOperations is equal to true.

Required 2

Impersonation is required.

Examples

The following code example on the service shows how to have a method impersonate the caller by using the OperationBehaviorAttribute to set the impersonation level.

C#
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public double Add(double n1, double n2)
{
    double result = n1 + n2;
    Console.WriteLine("Received Add({0},{1})", n1, n2);
    Console.WriteLine("Return: {0}", result);
    DisplayIdentityInformation();
    return result;
}

Remarks

Use the ImpersonationOption enumeration to control impersonation in Windows Communication Foundation (WCF) applications.

This setting interacts with a configuration property on ImpersonateCallerForAllOperations in the following table.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1