W
whitneje
I have been trying to create an event handler to modify a project using the
project OnCreated method. I created a second console program for testing my
PSI calls before actually creating and uploading the OnCreated dll. The
console app would work fine for testing the code, but whenever I created the
event handler dll it would crash with the following error messages:
Category: Project Server - General
EventID: 7952
Message: Critical PSI Auth: Username 'XX\myuser' passed in is not valid is
project database.
Category: Project Server Server-Side Even
EventID: 6663
Message: Critical Event Handler "AHProjectEvents.ProjectEventHandler" threw
an exception: The request failed with HTTP status 401: Unauthorized.
at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
at AHProjectEvents.WebSvcProject.Project.ReadProject(Guid projectUid,
DataStoreEnum dataStore)
at AHProjectEvents.ProjectEventHandler.OnCreated(PSContextInfo
contextInfo, ProjectPostEventArgs e)
I beat my head against this problem for 2 days. I was using impersonation,
and my user had all the authority it needed. The event handler was getting
registered. The problem ended up being the following line in my event handler:
bool isWindowsAccount = contextInfo.IsWindowsUser;
ProjectDerived.SetImpersonationContext(isWindowsAccount,
contextInfo.UserName, contextInfo.UserGuid, trackingGuid,
contextInfo.SiteGuid, LANGUAGE_ID);
For some reason contextInfo.IsWindowsUser kept return false even though my
account is a windows user.
SOLUTION:
I change the line to:
bool isWindowsAccount = true;
ProjectDerived.SetImpersonationContext(isWindowsAccount,
contextInfo.UserName, contextInfo.UserGuid, trackingGuid,
contextInfo.SiteGuid, LANGUAGE_ID);
Now it works perfectly. I'm not sure why contextInfo doesn't have the
appropriate information about my account, but hard coding true works for me.
This solution may not work if you are using forms authentication.
I was never able to find out any details about the EventID: 7952. Has anyone
else seen this before? I hope this helps.
project OnCreated method. I created a second console program for testing my
PSI calls before actually creating and uploading the OnCreated dll. The
console app would work fine for testing the code, but whenever I created the
event handler dll it would crash with the following error messages:
Category: Project Server - General
EventID: 7952
Message: Critical PSI Auth: Username 'XX\myuser' passed in is not valid is
project database.
Category: Project Server Server-Side Even
EventID: 6663
Message: Critical Event Handler "AHProjectEvents.ProjectEventHandler" threw
an exception: The request failed with HTTP status 401: Unauthorized.
at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
at AHProjectEvents.WebSvcProject.Project.ReadProject(Guid projectUid,
DataStoreEnum dataStore)
at AHProjectEvents.ProjectEventHandler.OnCreated(PSContextInfo
contextInfo, ProjectPostEventArgs e)
I beat my head against this problem for 2 days. I was using impersonation,
and my user had all the authority it needed. The event handler was getting
registered. The problem ended up being the following line in my event handler:
bool isWindowsAccount = contextInfo.IsWindowsUser;
ProjectDerived.SetImpersonationContext(isWindowsAccount,
contextInfo.UserName, contextInfo.UserGuid, trackingGuid,
contextInfo.SiteGuid, LANGUAGE_ID);
For some reason contextInfo.IsWindowsUser kept return false even though my
account is a windows user.
SOLUTION:
I change the line to:
bool isWindowsAccount = true;
ProjectDerived.SetImpersonationContext(isWindowsAccount,
contextInfo.UserName, contextInfo.UserGuid, trackingGuid,
contextInfo.SiteGuid, LANGUAGE_ID);
Now it works perfectly. I'm not sure why contextInfo doesn't have the
appropriate information about my account, but hard coding true works for me.
This solution may not work if you are using forms authentication.
I was never able to find out any details about the EventID: 7952. Has anyone
else seen this before? I hope this helps.