Reputation: 117
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
Upvotes: 1
Views: 1055
Reputation: 667
Have you tried setting the credential using
projContext.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
Upvotes: 0
Reputation: 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;
}
Upvotes: -1
Reputation: 1
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;
}
Upvotes: 0