ImpersonationOption 枚举
定义
指定服务实例中服务操作的模拟行为。Specifies the impersonation behavior for a service operation on a service instance.
public enum class ImpersonationOption
public enum ImpersonationOption
type ImpersonationOption =
Public Enum ImpersonationOption
- 继承
字段
| Allowed | 1 | 如果凭据可用并且 ImpersonateCallerForAllOperations 等于 |
| NotAllowed | 0 | 不执行模拟。Impersonation is not performed. 如果 ImpersonateCallerForAllOperations 等于 |
| Required | 2 | 需要进行模拟。Impersonation is required. |
示例
下面的服务代码示例演示如何使方法通过使用 OperationBehaviorAttribute 设置模拟级别来模拟调用方。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.
[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;
}
<OperationBehavior(Impersonation := ImpersonationOption.Required)> _
Public Function Add(ByVal n1 As Double, ByVal n2 As Double) As Double Implements ICalculator.Add
Dim result = n1 + n2
Console.WriteLine("Received Add({0},{1})", n1, n2)
Console.WriteLine("Return: {0}", result)
DisplayIdentityInformation()
Return result
End Function
注解
使用 ImpersonationOption 枚举来控制 Windows Communication Foundation (WCF) 应用程序的模拟。Use the ImpersonationOption enumeration to control impersonation in Windows Communication Foundation (WCF) applications.
此设置与下表中 ImpersonateCallerForAllOperations 的配置属性交互。This setting interacts with a configuration property on ImpersonateCallerForAllOperations in the following table.