SPSite Constructor (Guid, SPUserToken)
Initializes a new instance of the SPSite class based on the specified site collection GUID and user token.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
Syntax
'Declaration
<SubsetCallableExcludeMemberAttribute(SubsetCallableExcludeMemberType.PerSpec)> _
Public Sub New ( _
id As Guid, _
userToken As SPUserToken _
)
'Usage
Dim id As Guid
Dim userToken As SPUserToken
Dim instance As New SPSite(id, userToken)
[SubsetCallableExcludeMemberAttribute(SubsetCallableExcludeMemberType.PerSpec)]
public SPSite(
Guid id,
SPUserToken userToken
)
Parameters
id
Type: System.GuidA GUID that specifies the site collection.
userToken
Type: Microsoft.SharePoint.SPUserTokenAn SPUserToken object that represents the user token.
Remarks
SPSite objects that are created with a user token run in the context of the specified user. The current code must have the SharePointPermission.Impersonate code access security (CAS) permission. It is not possible to change the user context of an SPSite object after it is created. Switching users requires the creation of a new SPSite object.
Pluggable membership and role providers that are making a request must match the provider on the resource side.
Use the UserToken property to get the user token that is associated with any SPUser object, not just the current user. If the requested user is not the current user, SharePoint Foundation first tries to retrieve the cached user token from the database. If no token is cached, or if the cached token is stale, SharePoint Foundation rebuilds the token from the security ID (SID) of the user, and gets the group membership information using the authorization object model (see Authorization, Users, and Groups).