Partager via


Classe CallerImpersonationScope

S'applique à: CRM 2015 on-prem, CRM Online

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

Espace de noms: Microsoft.Xrm.Sdk
Assembly: Microsoft.Xrm.Sdk (dans Microsoft.Xrm.Sdk.dll)

Syntaxe

'Déclaration
Public NotInheritable Class CallerImpersonationScope
    Implements IDisposable
public sealed class CallerImpersonationScope : IDisposable

Remarques

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

Hiérarchie d'héritage

System.Object
  Microsoft.Xrm.Sdk.CallerImpersonationScope

Cohérence de thread

Tous les membres statiques publics (Shared dans Visual Basic) de ce type sont thread-safe. Tous les membres d'instance ne sont pas garantis thread-safe.

Plateformes

Plateformes de développement

Windows Vista, Windows Server 2003 et

Plateformes cibles

Windows Vista,Windows XP

Change History

Voir aussi

Référence

Membres CallerImpersonationScope
Espace de noms Microsoft.Xrm.Sdk

Autres ressources

Impersonate Another User

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