Avoiding Suspending Impersonation of the Calling User

Applies to: SharePoint Foundation 2010

If you use Windows authentication and your code calls the Microsoft SharePoint Foundation object model from an Internet Information Services (IIS) worker process, the request must impersonate the calling user’s identity. SharePoint Foundation configures Microsoft ASP.NET to impersonate the calling user automatically. If you suspend impersonation, your code may work in unexpected ways, or fail. Two examples of how your code might suspend impersonation:

Even if your code does not revert to self by using one of these methods explicitly, the caller of your code might have reverted to self without your knowledge. For example, ASP.NET suspends impersonation before it calls a custom virtual path provider.

See Also

Concepts

Best Practices with SharePoint Foundation