Deli z drugimi prek


CallerImpersonationScope Class

Definition

Identifies a user as the owner of all data changes made by calls to a Web service.

public ref class CallerImpersonationScope sealed : IDisposable
public sealed class CallerImpersonationScope : IDisposable
type CallerImpersonationScope = class
    interface IDisposable
Public NotInheritable Class CallerImpersonationScope
Implements IDisposable
Inheritance
CallerImpersonationScope
Implements

Remarks

The specified user does not have to be the same user that instantiated the service. When the CallerImpersonationScope object goes out of scope and is disposed, calls to the service are owned by the original user that instantiated the service.

using (new CallerImpersonationScope(service, userId))
{
   // Display information about the logged on user.
   Guid effectiveUserId = ((WhoAmIResponse)service.Execute(new WhoAmIRequest())).UserId;
   SystemUser systemUser = (SystemUser)service.Retrieve("systemuser", effectiveUserId, 
       new ColumnSet(new string[] {"firstname", "lastname"}));
   Console.WriteLine("Logged on user is {0} {1}.", systemUser.FirstName, systemUser.LastName);
}

Constructors

CallerImpersonationScope(IOrganizationService, Guid)

Initializes a new instance of the CallerImpersonationScope class.

Methods

Dispose()

Disposes the CallerImpersonationScope object.

Applies to