Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An example for impersonate a service reference call
namespace how.To.Impersonate.Service.Reference.Call
{
public static class CurrentUserDataHelper
{
public static String GetCurrentUserId()
{
var administrationService = GetServiceReferenceInstance();
var identity = (WindowsIdentity)HttpContext.Current.User.Identity;
administrationService.Credentials = CredentialCache.DefaultCredentials;
using (var impersonationContext = identity.Impersonate())
{
return administrationService.CurrentUsers.ToList().First().Identity;
}
}
private static Contracts.CurrentUserData.Administration GetServiceReferenceInstance()
{
return new Contracts.CurrentUserData.Administration(new Uri(ConfigurationManager.AppSettings["AKey"]));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.