Impersonation does not work when you use the SharePoint Portal Server object model or the Windows SharePoint Services object model to impersonate an authenticated user (892866)
The information in this article applies to:
- Microsoft Office SharePoint Portal Server 2003
- Microsoft Windows SharePoint Services
SYMPTOMSYou write code that uses the Microsoft Office SharePoint Portal Server object model or the Microsoft Windows SharePoint Services object model to try to impersonate an authenticated user in one or both of the following contexts: - In the context of a Web Part
- In the context of a program that runs under an anonymous user or of a program that runs under a non-authenticated user
However, impersonation does not work with some SharePoint Portal Server object model calls or with some Windows SharePoint Services object model calls. You may receive an error message that is similar to the following: Access is Denied For example, you may experience this symptom in the following scenario: - Impersonation code is called from a Web part or from console code that runs under an anonymous user.
- Impersonation code is called to make sure that an administrator account is used in this context.
- The call to the SPWeb.Roles collection in this scenario fails.
- The following code is run:
SPSite siteCollection = new SPSite("http://localhost");
SPWeb web2 = siteCollection.OpenWeb();
SPRole adminRole = web2.Roles["Administrator"]; - The access to the web2.Roles collection fails.
CAUSEImpersonation is not currently supported in the SharePoint Portal Server object model or in the Windows SharePoint Services object model. This functionality is being investigated for future versions of the object models.
Modification Type: | Minor | Last Reviewed: | 10/12/2006 |
---|
Keywords: | kbProgramming kberrmsg kbprb KB892866 kbAudITPRO kbAudDeveloper |
---|
|