Use the SystemAccount Property When Building SPUserToken Objects
I saw a developer doing this with some funky impersonation today, so I thought I would throw out some sample code. Consider the below shell code, demonstrating the SPSite.SystemAccount property use, subsequently using it to expose the SystemAccount.Token property to pass into the SPSite constructor.
C#:
-
SPWeb primaryWeb = SPContext.Current.Web;
-
{
-
SPUserToken userToken = primarySite.SystemAccount.UserToken;
-
{
-
using (SPWeb secondaryWeb =secondarySite.OpenWeb(primaryWeb.ID))
-
{
-
-
try
-
{
-
-
}
-
catch (Exception)
-
{
-
}
-
-
}
-
}
-
}
1 Comment »
RSS feed for comments on this post. TrackBack URL























Articles & Research
SharePoint Architecture
Personal/Off-Topic
Article Or Research Filed Under 

[...] Use the SystemAccount Property When Building SPUserToken Objects [...]
Pingback by Links (10/18/2009 « Steve Pietrek – Everything SharePoint) — October 18, 2009 @ 5:31 pm