1

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

LittleBobbyTables - Au Revoir
  • 32,008
  • 25
  • 109
  • 114
David
  • 97
  • 9
  • Did you modify your app.config yet? Look at the second half of [my answer here](http://stackoverflow.com/questions/2608887/sharepoint-web-services-the-http-request-is-unauthorized-with-client-authenti/2609909#2609909) to see the section you will need to modify. – Kit Menke Feb 20 '13 at 13:20
  • @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 Mar 04 '13 at 10:08

3 Answers3

0
    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

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

Ariwibawa
  • 627
  • 11
  • 23
-1

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;
}
Linh
  • 57,942
  • 23
  • 262
  • 279
  • Your solution doesn't correspond to my need. I want to use current user credentials, not hard coded ones... – David Jun 03 '16 at 07:58