1
votes

I'm migrating code from 2010 to 2013.

I have a user control that I deploy in Sharepoint that calls the PSI. In 2010 it was working well. Now in 2013 and Claims authentication, I always get: "The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'NTLM,Negotiate'." when I call any PSI (even GetCurrentUserUid) with any user (even the project admin).

It looks like the credentials aren't passed to the PSI and it calls them as anonymous. Anyone can help ?

Another example of code I execute from Sharepoint:

ProjectContext projContext = new ProjectContext(PROJECT_SERVER_URL);
projContext.Load(projContext.EnterpriseResources);
projContext.ExecuteQuery();

I get access denied.

Thanks

3
Did you modify your app.config yet? Look at the second half of my answer here to see the section you will need to modify.Kit Menke
@Kit in my case it would be the web.config. I configure the client by code so there is nothing in the web.config. this.HttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);this.HttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;David

3 Answers

0
votes
    public static ProjectContext GetContext()
    {
        ProjectContext projContext;
        using (projContext = new ProjectContext("pwaUrl"))
        {
            SecureString passWord = new SecureString();

            foreach (char c in "YourEmailPassword".ToCharArray()) passWord.AppendChar(c);

            projContext.Credentials = new SharePointOnlineCredentials("YourEmail", passWord);
        }
        return projContext;
    }
0
votes

Have you tried setting the credential using projContext.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

-1
votes

You need to logon to SharePoint first. The bit below will give you a valid context.

public static ProjectContext GetContext()
{
    ProjectContext projContext;
    using (projContext = new ProjectContext("pwaUrl"]))
    {
        SecureString passWord = new SecureString();

        foreach (char c in "yourPassword".ToCharArray()) passWord.AppendChar(c);

        projContext.Credentials = new SharePointOnlineCredentials("youremailaddress", passWord);
    }
    return projContext;
}