CSOM C# 连接到 Project Server
CSOM C# connect with Project Server
我已经问过类似的问题,我认为我正在取得进展。好吧,事实证明我被困在自动取款机上了。
我正在尝试连接到 Project Online Server,但无法连接。
string pwaPath = "Url";
ProjectContext projContext = new ProjectContext(pwaPath);
// Get the list of projects in Project Web App.
SecureString password = new SecureString();
foreach (char c in "password".ToCharArray()) password.AppendChar(c);
//Using SharePoint method to load Credentials
projContext.Credentials = new SharePointOnlineCredentials(@"domain\user", password);
var projects = projContext.Projects;
int j = 0;
projContext.Load(projects);
projContext.ExecuteQuery();
foreach (PublishedProject pubProj in projContext.Projects)
{
Console.WriteLine("\n{0}. {1} {2} \t{3} \n", j++, pubProj.Id, pubProj.Name, pubProj.CreatedDate);
}
这是我的测试代码。使用 SharePointOnlineCredentials 我收到错误
System.ArgumentException: 'The 'username' argument is invalid.'
所以我尝试使用 user@xxx.com 作为用户并得到了
The response header value is 'NTLM'
因此,我尝试使用 NetworkCredential 并收到此错误:
The specified server may not support APIs used in this operation.
我最后的希望是测试 FormsAuthentication。这是代码和我得到的错误
projContext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;
FormsAuthenticationLoginInfo formsAuthInfo = new FormsAuthenticationLoginInfo("user", "password");
projContext.FormsAuthenticationLoginInfo = formsAuthInfo;
'Server was unable to process request. ---> Site is not configured for Claims Forms Authentication.
也许有人知道我可以尝试什么。
发现错误。我必须从服务器添加 dll 作为参考,而不是 Nuget Microsoft.SharePointOnline.CSOM
我已经问过类似的问题,我认为我正在取得进展。好吧,事实证明我被困在自动取款机上了。
我正在尝试连接到 Project Online Server,但无法连接。
string pwaPath = "Url";
ProjectContext projContext = new ProjectContext(pwaPath);
// Get the list of projects in Project Web App.
SecureString password = new SecureString();
foreach (char c in "password".ToCharArray()) password.AppendChar(c);
//Using SharePoint method to load Credentials
projContext.Credentials = new SharePointOnlineCredentials(@"domain\user", password);
var projects = projContext.Projects;
int j = 0;
projContext.Load(projects);
projContext.ExecuteQuery();
foreach (PublishedProject pubProj in projContext.Projects)
{
Console.WriteLine("\n{0}. {1} {2} \t{3} \n", j++, pubProj.Id, pubProj.Name, pubProj.CreatedDate);
}
这是我的测试代码。使用 SharePointOnlineCredentials 我收到错误
System.ArgumentException: 'The 'username' argument is invalid.'
所以我尝试使用 user@xxx.com 作为用户并得到了
The response header value is 'NTLM'
因此,我尝试使用 NetworkCredential 并收到此错误:
The specified server may not support APIs used in this operation.
我最后的希望是测试 FormsAuthentication。这是代码和我得到的错误
projContext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;
FormsAuthenticationLoginInfo formsAuthInfo = new FormsAuthenticationLoginInfo("user", "password");
projContext.FormsAuthenticationLoginInfo = formsAuthInfo;
'Server was unable to process request. ---> Site is not configured for Claims Forms Authentication.
也许有人知道我可以尝试什么。
发现错误。我必须从服务器添加 dll 作为参考,而不是 Nuget Microsoft.SharePointOnline.CSOM