Document library event handlers that use object model code without explicit impersonation fail with the "Cannot complete this action" error message after Windows SharePoint Services Service Pack 2 is installed (909455)



The information in this article applies to:

  • Microsoft Office SharePoint Portal Server 2003
  • Microsoft Windows SharePoint Services

SYMPTOMS

After you install Microsoft Windows SharePoint Services (WSS) Service Pack 2 (SP2), the document library event handlers that use object model code without explicit impersonation fail. Additionally, you receive the following error message.
Cannot complete this action

CAUSE

In the versions of Microsoft Windows SharePoint Services that are earlier than Windows SharePoint Services SP2, you could write a document library event handler that used the object model without explicit impersonation to access Windows SharePoint Services. However, you could only use this kind of implicit call if the application pool identity was a user who had sufficient rights to make object model calls.

In Windows SharePoint Services SP2, security has been increased in such a way that this kind of call is no longer possible. Therefore, you receive an error message if you try to perform this kind of call.

WORKAROUND

All document library event handlers must perform explicit impersonation to use Windows SharePoint Services object model calls. If the application pool identity has sufficient rights to make Windows SharePoint Services object model calls, you can use a code that impersonates the current user. The following code is an example of this kind of code:
using System.Security.Principal

...

WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate();

//implement OM code here

wic.Undo();

STATUS

This behavior is by design.

MORE INFORMATION

For more information about impersonating and reverting, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:10/18/2005
Keywords:kbprb KB909455 kbAudDeveloper kbAudITPRO