Compartilhar via


Classe CallerImpersonationScope

Aplica-se a: CRM 2015 on-prem, CRM Online

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

Namespace: Microsoft.Xrm.Sdk
Assembly: Microsoft.Xrm.Sdk (em Microsoft.Xrm.Sdk.dll)

Sintaxe

'Declaração
Public NotInheritable Class CallerImpersonationScope
    Implements IDisposable
public sealed class CallerImpersonationScope : IDisposable

Comentários

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);
}

Hierarquia de Herança

System.Object
  Microsoft.Xrm.Sdk.CallerImpersonationScope

Segurança do Thread

Todos os membros estáticos (Shared in Visual Basic) desse tipo são protegidos por thread. Não há nenhum garantia de que os membros de instância sejam protegidos por thread.

Plataformas

Plataformas de desenvolvimento

Windows Vista, Windows Server 2003 e

Plataformas de destino

Windows Vista,Windows XP

Change History

Consulte também

Referência

Membros de CallerImpersonationScope
Namespace Microsoft.Xrm.Sdk

Outros recursos

Impersonate Another User

Send comments about this topic to Microsoft.
© 2014 Microsoft Corporation. All rights reserved.