Tuesday, 25 March 2014

The remote server returned an error 401 unauthorized in SharePoint 2013

The remote server returned an error 401 unauthorized in SharePoint 2013
Solution:
System.Security.Principal.WindowsImpersonationContext impersonationContext;
impersonationContext =
((System.Security.Principal.WindowsIdentity)Thread.CurrentPrincipal.Identity).Impersonate();
impersonationContext.Undo();