【问题标题】:To involve SharePoint WCF Service with SSL-Certificate from Client laptop failed使用来自客户端笔记本电脑的 SSL 证书涉及 SharePoint WCF 服务失败
【发布时间】:2019-11-10 16:37:12
【问题描述】:

我的测试环境是:

  • 1* 带有 WCF 服务的服务器 :: SharePoint 站点(在 ISAPI 文件夹中),我们在其上配置了 SSL 和证书。
  • 1* 客户端 :: Windows 10 带有一个控制台应用程序以涉及 WCF 服务

测试(一):SharePoint Server 上的所有程序(WCF 服务和控制台应用程序)

我创建了一个控制台应用程序来调用 SharePoint 中的 WCF 服务。同时,控制台应用程序和 WCF 位于同一台服务器上。结果是一切正常。上传文件到文档库成功。

测试(2):模拟我的客户端环境:

  • 1* SharePoint :WCF 服务
  • 1* Windows 10:控制台应用程序

结果失败,我收到错误消息:

HTTP 请求未经客户端身份验证方案“匿名”授权。从服务器收到的身份验证标头是“NTLM”

说实话,我在这里停留了一段时间。我还列出了我的部分源代码供有经验的人查看。我还在here 中发布了一些示例代码和web.config。

【问题讨论】:

  • 请将源代码 web.config here 发布在问题中,而不是在某些第三方网站上。
  • 您的控制台应用程序必须验证到 SharePoint。您收到的错误消息表明它没有传递任何凭据(“匿名”),而服务器配置为期望 NTLM 身份验证。
  • 嗨 Ondrej,我想在这里发布 web.config。但是 XML 字符串太长了,超出了限制......所以我仍然上传到我的 office365。如果你愿意下载,请从这里[link]spexphk-my.sharepoint.com/:u:/g/personal/…

标签: c# wcf sharepoint ssl-certificate


【解决方案1】:

已更新。
如果我们启用 NTLM 身份验证,我们必须启用 windows 身份验证。

那么在调用服务时,我们需要提供windows凭据。

//it will use the binding and service endpoint address in the system.servicemode section.
        ServiceReference1.ServiceClient client = new ServiceReference1.ServiceClient();
                //windows account on the server.
                client.ClientCredentials.Windows.ClientCredential.UserName = "administrator";
                client.ClientCredentials.Windows.ClientCredential.Password = "abcd1234!";
                try
                {
                    Console.WriteLine(client.SayHello());
                }
                catch (Exception)
                {
                    throw;
                }

自动生成的配置。

   <system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IService">
                <security mode="Transport">
                    <transport clientCredentialType="Ntlm" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://vabqia969vm:21011/" binding="wsHttpBinding"
            bindingConfiguration="WSHttpBinding_IService" contract="ServiceReference1.IService"
            name="WSHttpBinding_IService">
            <identity>
                <userPrincipalName value="VABQIA969VM\Administrator" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

如果问题仍然存在,请随时告诉我。

【讨论】:

  • Hi Abraham,(1) Windows 身份验证 --> 默认启用 (2) extlab.litwareinc.pri... --> 可以连接 (3) 为什么我使用以下代码连接到服务 --> 当我使用 BasicHttpBinding 时,我使用相同的代码来完成它并正常工作。所以我们只要把BaiscHttpBinding改成WSHttpBinding,大部分源代码都是一样的。当然,security.mode 或 transport 会有所不同。你可以从 [link]spexphk-my.sharepoint.com/:u:/g/personal/… 下载它
  • 嗨 Abraham,“服务地址应该在客户端配置文件中自动生成。” --> 你的意思是我需要为 SharePoint WebPart、控制台或其他类型的程序创建一个配置文件??但是当我使用 BasicHttpBinding 并使用窗口身份验证时,我不这样做并且正常工作
  • 不,如果我们通过客户端代理调用服务,我们通常通过添加服务引用来生成。同时,配置文件中的 System.servicemodel 部分也会自动生成。因此我想检查配置。另外,您在调用服务时是否提供了用户名/密码?
  • ServiceReference1.ServiceClient client = new ServiceClient(); client.ClientCredentials.UserName.UserName = "管理员"; client.ClientCredentials.UserName.Password = "abcd1234!";
  • 亚伯拉罕,我分享了 web.config 的 url ([link]1drv.ms/t/s!Aj2Mcyp8XWC1g8t8hC8agR6rhgU-Aw)。请参考链接。谢谢。 [同时,配置文件中的 System.servicemodel 部分也会自动生成] --> 这意味着即使我从 VS .NET 添加了 WCF 服务,我还需要再次使用生成的所有设置???另一件事是我昨天在我的源代码中提供了用户名/密码并试了一下。出现相同的错误消息。我怀疑我的证书是否配置不正确......
猜你喜欢
  • 1970-01-01
  • 2016-10-24
  • 2023-03-30
  • 2014-02-23
  • 2011-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多