【问题标题】:Project Server 2013 PSI calls from Sharepoint 2013来自 Sharepoint 2013 的 Project Server 2013 PSI 调用
【发布时间】:2013-02-04 09:29:19
【问题描述】:

我正在将代码从 2010 年迁移到 2013 年。

我在 Sharepoint 中部署了一个调用 PSI 的用户控件。 2010 年,它运作良好。现在在 2013 年和声明身份验证中,我总是得到:“HTTP 请求未经客户端身份验证方案'Ntlm' 的授权。从服务器收到的身份验证标头是'NTLM,Negotiate'。”当我与任何用户(甚至项目管理员)调用任何 PSI(甚至 GetCurrentUserUid)时。

看起来凭据没有传递给 PSI,它称它们为匿名。有人可以帮忙吗?

我从 Sharepoint 执行的另一个代码示例:

ProjectContext projContext = new ProjectContext(PROJECT_SERVER_URL);
projContext.Load(projContext.EnterpriseResources);
projContext.ExecuteQuery();

我的访问被拒绝。

谢谢

【问题讨论】:

  • 您是否修改了您的 app.config?查看my answer here 的后半部分,查看您需要修改的部分。
  • @Kit 在我的例子中是 web.config。我通过代码配置客户端,因此 web.config 中没有任何内容。 this.HttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);this.HttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;

标签: sharepoint-2013 psi ms-project-server-2013


【解决方案1】:

您是否尝试过使用 projContext.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

【讨论】:

  • 应该是评论
  • 我无法添加评论
【解决方案2】:

您需要先登录到 SharePoint。下面的内容将为您提供一个有效的上下文。

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;
}

【讨论】:

  • 您的解决方案不符合我的需要。我想使用当前用户凭据,而不是硬编码的……
【解决方案3】:
    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;
    }

【讨论】:

    猜你喜欢
    • 2015-07-09
    • 2016-10-21
    • 2014-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多