簡體   English   中英

CSOM C#與Project Server連接

[英]CSOM C# connect with Project Server

我已經問過類似的問題,並且我認為自己正在取得進步。 好吧,事實證明我很難堅持atm。

我正在嘗試連接到Project Online服務器,但不能。

        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:'用戶名'參數無效。

所以我嘗試使用user@xxx.com作為用戶並得到

響應標頭值為“ NTLM”

因此,我嘗試使用NetworkCredential並收到此錯誤:

指定的服務器可能不支持此操作中使用的API。

我最后的希望是測試FormsAuthentication。 這是代碼和我得到的錯誤

projContext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;    
FormsAuthenticationLoginInfo formsAuthInfo = new  FormsAuthenticationLoginInfo("user", "password");
projContext.FormsAuthenticationLoginInfo = formsAuthInfo;

'服務器無法處理請求。 --->未為“聲明表單身份驗證”配置站點。

也許有人知道我可以嘗試的方法。

發現了錯誤。 我必須添加服務器中的dll作為參考,而不是Nuget Microsoft.SharePointOnline.CSOM

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM