PSI身份验证仅返回401

时间:2011-10-24 17:47:50

标签: web-services visual-studio-2010 ms-project-server-2010

我正在开发一个网络服务,它将成为许多应用程序和PSI之间的“守门人”。问题是“许多应用程序”将提供登录/密码,并且Web服务必须针对PSI对它们进行身份验证。但无论我做什么,当我调用“PSIFormsLogin.Login(用户,密码)”方法时,我总是得到401 Unauthorized错误...我甚至使用了运行农场的用户......

我已经按照以下MS教程:http://msdn.microsoft.com/en-us/library/ff181538.aspx

最后我想做的就是验证使用PSI网络服务提供的帐户/密码,任何人都可以告诉我,我做错了什么???

PS:不是WCF

新信息:有趣的事情发生了。我故意将网址切换为不存在的http://myserver/pwa/_vti_bin/psi/bla.asmx,但我仍然有401 ...

1 个答案:

答案 0 :(得分:0)

确保您已修改了此应用程序的web.config。只需覆盖绑定节点中的安全节点:

<binding name="WssInteropSoap">
  <security mode="TransportCredentialOnly">
    <transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm"
        realm="" />
    <message clientCredentialType="UserName" algorithmSuite="Default" />
  </security>
</binding>

现在您可以在没有特殊帐户(来自Windows的密码)的情况下进行身份验证,或者使用此代码,您可以指定一个帐户:

//credential impersonation (just if you changed your binding settings)
projectSvc.ClientCredentials.Windows.ClientCredential = new NetworkCredential("username", "password", "domain");
projectSvc.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

我希望它会有所帮助:)

但是,我从来没有听说过一个名为“PSIFormsLogin.Login”的函数

也许我的博客条目用于设置与C#的PSI连接对您有意义:Read Project Server 2010 CustomFields over PSI