Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

Impersonating Anyone From Code Yields 401: Unauthorized on next PSI call

$
0
0

Hello Everyone,

I am running an event handler and I am trying to impersonate an administrator, but evertime I make a PSI call as that account, I get a 401 unauthorized error.

By default, the event runs under the spFarm account, and when I just use default credentials everything works fine, but as soon as I try to impersonate this spFarm user, PSI calls fail.

//get the user GUID Guid userGuid = new Guid( LoadParameterValueFromXML( settingsXml, "userGuid" ) ); //Get the domain name string domainName = LoadParameterValueFromXML( settingsXml, "domainName" ); //get the site Guid SPSite pwaSite = new SPSite( PWAUrl ); Guid siteUID = pwaSite.ID;

//set the impersonation ProjectDerived.SetImpersonationContext( true, domainName, userGuid, Guid.NewGuid(), siteUID ); SecurityDerived.SetImpersonationContext( true, domainName, userGuid, Guid.NewGuid(), siteUID ); LookupTableDerived.SetImpersonationContext( true, domainName, userGuid, Guid.NewGuid(), siteUID );

After this code I make a call to read project entities and that is when I get the unauthorized error. Yes, I have double checked the domain name and User GUID to ensure they are accurate. Any ideas as to why impersonating anyone, even an admin, will fail?


120811049008


Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>