Project 2013 PSI wcf连接问题 [英] Project 2013 PSI wcf connection problem

查看:66
本文介绍了Project 2013 PSI wcf连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目Web访问应用程序(PWA)上发布了Web部件,并通过wcf服务连接到  / _ vti_bin / PSI / ProjectServer.svc。 Web部分抛出异常:

Hi, I have web part published on project web access application (PWA) and connects to /_vti_bin/PSI/ProjectServer.svc through wcf service. Web part throws exception:

System.ServiceModel.Security.MessageSecurityException:HTTP请求未经授权使用客户端身份验证方案'Ntlm'。

从服务器收到的身份验证标头是'NTLM'。 ---> System.Net.WebException:远程服务器返回

错误:(401)未经授权。

                                      
| 服务器堆栈跟踪:                                       |    
在System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest的请求,HttpWebResponse响应,引发WebException responseException,HttpChannelFactory`1工厂)          &NBSP ;                        &NBSP ; 
|    在

系统。 ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest的请求,HttpWebResponse响应,HttpChannelFactory`1工厂,引发WebException responseException,
channelBinding channelBinding)          &NBSP ;                        &NBSP ;  |    
in

System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度超时)              &NBSP ;                      
|    在System.ServiceModel.Channels.RequestChannel.Request(消息消息,时间跨度超时)                &NBSP ;                    
|    在System.ServiceModel.Channels.ServiceChannel.Call(字符串动作,布尔单向,ProxyOperationRuntime操作,对象[]项,对象[]奏,时间跨度超时)        &NBSP ;                        &NBSP ;   
|    在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage包括MethodCall,ProxyOperationRuntime操作)                &NBSP ;                    
|    在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

 这是创建绑定点的代码,它在控制台应用程序中工作正常(但在Web部件中抛出异常):

private static ProjectClient CreateProjectClient(string pwaUrl)
        {
            const int maxsize = 500000000;
            const string svcUrl = "/_vti_bin/PSI/ProjectServer.svc";

            BasicHttpBinding binding = pwaUrl.Contains("https:") ?
                new BasicHttpBinding(BasicHttpSecurityMode.Transport) :
                new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);

            binding.Name = "basicHttp_Project";
            binding.SendTimeout = TimeSpan.MaxValue;
            binding.MaxReceivedMessageSize = maxsize;
            binding.ReaderQuotas.MaxNameTableCharCount = maxsize;
            binding.MessageEncoding = WSMessageEncoding.Text;
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
            binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Ntlm;
            binding.UseDefaultWebProxy = false;
            var address = new EndpointAddress(SPUrlUtility.CombineUrl(pwaUrl, svcUrl));
            var client = new ProjectClient(binding, address);
            if ((client.ChannelFactory != null) && (client.ChannelFactory.Credentials != null))
            {
                client.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
                client.ChannelFactory.Credentials.Windows.AllowNtlm = true;
            }
            return client;
        }

当我定义凭证

client.ClientCredentials.Windows.ClientCredential = new NetworkCredential("login", "password", "domain");

但我需要在当前用户下运行。我也检查双跳问题和用户权限 - 没有运气。

but I need to run under current user. I'm also check double hop problem and user permissions - no luck.

我希望有人可以帮助我,谢谢。

I hope somebody can help me, thanks.






推荐答案

<您应该尝试:

客户端 ClientCredentials Windows ClientCredential =
CredentialCache.DefaultNetworkCredentials

client.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials

请将此回复标记为如果这对你有价值,请回答。

Please mark this reply as an answer if this was valuable for you.


这篇关于Project 2013 PSI wcf连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆