views:

114

answers:

2

When you create a Silverlight enabled WCF service, the following line is placed in the source file -

[AspNetCompatibilityRequirements(RequirementsMode =
    AspNetCompatibilityRequirementsMode.Allowed)]

What does it do? The online help didn't make a lot of sense to me.

A: 

I'm not familiar with this attribute, but this document states:

The ImpersonationOption is a three-value enum just as AspNetCompatibilityRequirementsMode: NotAllowed, Allowed, and Required. The default value is NotAllowed. If it is Allowed, you can turn on service-level impersonation from the following config flag “impersonateCallerForAllOperations”:

<behavior name="MyImp">
    <serviceAuthorization impersonateCallerForAllOperations="false"/>
</behavior>
There are two cases when a service operation is enabled for WCF impersonation:
* The operation has OperationBehavior.Impersonation set to “Required”.
* The operation has OperationBehavior.Impersonation set to “Allowed” and the 
  flag “impersonatedCallerForAllOperations” is set to true.
Rubens Farias
The linked article has some good info, but how does the rest of this answer relate to the question? I don't see any references to `ImpersonationOption` or anything related to impersonation at all.
RickNZ
+3  A: 

In compatibility mode, WCF services use the HTTP pipeline through an IHttpHandler implementation, similar to the way requests for ASPX pages and ASMX Web services are handled. As a result, WCF behaves identically to ASMX with respect to the following ASP.NET features:

* HttpContext: WCF services running in ASP.NET Compatibility Mode can access Current and its associated state.

* File-based authorization: WCF services running in ASP.NET compatibility mode can be secure by attaching file system access control lists (ACLs) to the service’s .svc file.

* Configurable URL authorization: ASP.NET’s URL authorization rules are enforced for WCF requests when the WCF service is running in ASP.NET Compatibility Mode.

* HttpModuleCollection extensibility: Because WCF services running in ASP.NET Compatibility Mode participate fully in the ASP.NET HTTP request lifecycle, any HTTP module configured in the HTTP pipeline is able to operate on WCF requests both before and after service invocation.

* ASP.NET Impersonation: WCF services run using the current identity of the ASP.NET impersonated thread, which may be different than the IIS process identity if ASP.NET impersonation has been enabled for the application. If ASP.NET impersonation and WCF impersonation are both enabled for a particular service operation, the service implementation ultimately runs using the identity obtained from WCF.
elsharpo