in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Mirjam's blog

Blogging about SharePoint related stuff

November 2006 - Posts

  • 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.


Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts