CSOM C#与Project Server连接

问题描述 投票:0回答:1

我已经提出了类似的问题,我认为我正在取得进展。事实证明我很难被困住。

我正在尝试连接到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:''username'参数无效。

所以我尝试使用[email protected]作为用户并得到了

响应头值为'NTLM'

因此,我尝试使用NetworkCredentialand出现此错误:

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

我最后的希望是测试FormsAuthentication。这是我得到的代码和错误

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

'服务器无法处理请求。 --->未为声明表单身份验证配置站点。

也许有人知道我可以尝试什么。

c# credentials csom ms-project project-server
1个回答
0
投票

发现了错误。我不得不从服务器添加dll作为参考,而不是Nuget Microsoft.SharePointOnline.CSOM

© www.soinside.com 2019 - 2024. All rights reserved.