【问题标题】:SharePoint 2010 WCF RESTful Authentication Issue with Anonymous Authentication Publishing Site匿名身份验证发布站点的 SharePoint 2010 WCF RESTful 身份验证问题
【发布时间】:2011-12-30 18:37:54
【问题描述】:

我有一个启用匿名访问的 SharePoint 2010 发布站点,但我在使用 WCF RESTful 数据访问时遇到了一些问题...

首先,当我尝试在 Visual Studio 2010 中为 listdata.svc 创建数据源时,它会失败,除非我进入 IIS 并禁用 _vti_bin 上的匿名身份验证。如果我在 _vti_bin 上禁用匿名身份验证,我可以添加数据源而不会出错。

其次,如果我在 _vti_bin 上禁用匿名身份验证并尝试与 SharePoint Designer 连接,则在提示输入我的用户名/密码后出现错误。

第三,如果我在 _vti_bin 上允许匿名身份验证并尝试运行我的 WCF RESTful 代码,则似乎未使用传入的凭据。查看代码

 static void Main(string[] args)
    {  
        MySite.MySiteDataContext dc = new MySite.MySiteDataContext(new Uri("http://mysite/_vti_bin/ListData.svc/"));

        dc.Credentials = new NetworkCredential("user", "password", "domain");


        var q = from m in dc.Products
                select m;


        foreach (var i in q)
        { 

           //never gets in here when Anonymous Authentication is allowed on the _vti_bin       
           //when Anonymous Authentication is disabled on _vti_bin this code runs without issue. 

        }
    }

所以...谁能告诉我我做错了什么或者是否有解决此问题的方法?

环境:

SharePoint 2010 启用匿名访问的发布站点 在控制台应用程序中运行的代码与 SharePoint Server 不在同一台服务器上。

【问题讨论】:

    标签: wcf sharepoint-2010 restful-authentication


    【解决方案1】:

    您应该创建一个如下所述的绑定。

    BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
    basicHttpBinding.MaxReceivedMessageSize = Int64.MaxValue; 
    basicHttpBinding.TransferMode = TransferMode.StreamedResponse; 
    basicHttpBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
    basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; 
    EndpointAddress endpoint = new EndpointAddress("yoururl"); 
    basicHttpBinding.CloseTimeout = new TimeSpan(0, 10, 0, 0); 
    basicHttpBinding.OpenTimeout = new TimeSpan(0, 10, 0, 0); 
    basicHttpBinding.ReceiveTimeout = new TimeSpan(0, 10,## Heading ## 0, 0);
    basicHttpBinding.SendTimeout = new TimeSpan(0, 10, 0, 0); 
    DataService.ServiceClient obj = new DataService.ServiceClient(basicHttpBinding, endpoint); 
    

    【讨论】:

      猜你喜欢
      • 2018-01-11
      • 2010-11-28
      • 1970-01-01
      • 2012-10-14
      • 2010-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多