November 2006 Entries

Impersonation in SharePoint 2007

In SharePoint 2003 there was no easy way to use impersonation. In SharePoint 2007 there is a nice and easy build in way to use impersonation: SPSite site = new SPSite("SiteCollection_Url");SPWeb web = site.OpenWeb();SPUser user = web.AllUsers["User_Name"]; SPUserToken token = user.UserToken;SPSite impersonatedSiteCollection = new SPSite("SiteCollection_Url", token); You can also check whether an SPSite object is using impersonation: SPSite siteCollection = SPControl.GetContextSite(HttpContext.Current);bool impersonating = siteCollection.Impersonating;

Hi!

Hi All, Welcome to my SharePoint blog. I'm a SharePoint developer at Macaw (http://www.macaw.nl) in the Netherlands. I will mainly be posting SharePoint 2007 stuff here.