none
Project Server 2013 PSI Impersonation RRS feed

  • Question

  • Hi, we are trying to use impersonation while accessing MS Project Server 2013 via PSI.
     
    We use the following function to set impersonation:

    private void SetImpersonationWebOperationContext(string userName, Guid userUid)
            {
                PSContextInfo contextInfo = new PSContextInfo(true, userName, userUid, Guid.Empty,
                    Guid.Empty, 0, CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
                    Guid.Empty, String.Empty);
                string contextInfoString = PSContextInfo.SerializeToString(contextInfo);

                using (OperationContextScope scope = new OperationContextScope(resourceClient.InnerChannel))
                {
                    // Use WebOperationContext in the HTTP channel, not the OperationContext.
                    if (WebOperationContext.Current != null)
                    {
                        WebOperationContext.Current.OutgoingRequest.Headers.Remove("PjAuth");
                        WebOperationContext.Current.OutgoingRequest.Headers.Add("PjAuth", contextInfoString);
                        // Disable Forms authentication, to enable Windows authentication.
                        DisableFormsAuth();
                    }
                }
            }
    and check the impersonation this way:

    public void TestImpersonation(string resourceName, Guid resourceUid, out Guid uidBefore, out Guid uidAfter)
            {            
                    uidBefore = resourceClient.GetCurrentUserUid();
                    SetImpersonationWebOperationContext(resourceName, resourceUid);
                    uidAfter = resourceClient.GetCurrentUserUid();
            }

    The issue is that the uidBefore is equal to the uidAfter. So it seems that the impersonation doesn't work. The account that we are using to do that has full controll acces in the project server. The code is based on the msdn article "How to: Use Impersonation with WCF" (can be found on msdn).


    Is it going to work for Project Server 2013, and if it is, then what are we doing wrong?  
     
    Any help/tip/advice would be much appreciated.
     
    Thanks

    Monday, February 13, 2017 3:33 PM