ImpersonationOption ImpersonationOption ImpersonationOption ImpersonationOption Enum

定义

指定服务实例中服务操作的模拟行为。Specifies the impersonation behavior for a service operation on a service instance.

public enum class ImpersonationOption
public enum ImpersonationOption
type ImpersonationOption = 
Public Enum ImpersonationOption
继承
ImpersonationOptionImpersonationOptionImpersonationOptionImpersonationOption

字段

Allowed Allowed Allowed Allowed 1

如果凭据可用并且 ImpersonateCallerForAllOperations 等于 true,将执行模拟。Impersonation is performed if credentials are available and ImpersonateCallerForAllOperations is equal to true.

NotAllowed NotAllowed NotAllowed NotAllowed 0

不执行模拟。Impersonation is not performed. 如果 ImpersonateCallerForAllOperations 等于 true,则服务启动时将会发生验证异常。If ImpersonateCallerForAllOperations is equal to true, a validation exception occurs at service startup time.

Required Required Required 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.

适用于