使用 WCF 连接到 SharePoint 并进行身份验证

发布于 2024-07-23 12:04:43 字数 1579 浏览 5 评论 0原文

我对这个很着迷,在任何地方都找不到任何像样的信息。

有很多关于使用 WCF 和 Ntlm 模拟连接到 SharePoint 3.0 Web 服务的信息。 但是,当访问 SharePoint 服务的客户端位于 SharePoint 网络远程并且需要进行身份验证时,如何最好地配置凭据并将其传递给 SharePoint 服务。

我可以在 servicemodel.config 内指定 SharePoint 框本地的 Windows 用户名和密码吗?我们的 SharePoint 实例在访问它的域之外作为独立运行。 因此,模拟是无关紧要的,因为共享点框中不存在域用户。

我尝试了许多组合,例如以下代码。但是,我反复遇到异常,例如:

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

任何人都可以提供使用 Windows 凭据连接到“远程”SharePoint Web 服务的示例吗?

ListsSoapClient proxy = new ListsSoapClient();

proxy.ClientCredentials.Windows.ClientCredential.UserName = "admin_user";
proxy.ClientCredentials.Windows.ClientCredential.Password = "admin_password";
proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Identification;

listItems = proxy.GetListItems(...);

proxy.Close();

绑定示例:

<security mode="TransportCredentialOnly">
  <transport clientCredentialType="Windows" proxyCredentialType="None" />
</security>

..

<security mode="TransportCredentialOnly">
  <transport clientCredentialType="Ntlm" />
</security> 

行为:

<behavior name="behavior_WSS">
  <clientCredentials>
    <windows allowedImpersonationLevel="Impersonation" allowNtlm="true" />
  </clientCredentials>
</behavior>

    <windows allowedImpersonationLevel="Delegation" allowNtlm="true" />

I'm going nuts with this one and can't find any decent information ANYWHERE ..

There is lots of info around about connecting to SharePoint 3.0 Web Services with WCF and Ntlm impersonation. However, when the client accessing the SharePoint services is remote to the SharePoint network and needs to authenticate, how does one best configure and pass credentials to the SharePoint service.

Can I specify a windows username and password local to the SharePoint box inside the servicemodel.config .. our SharePoint instance is running as standalone outside the domain that is accessing it. Therefore impersonation is irrelevant as the domain users do not exist on the sharepoint box.

I have tried many combinations like the following codes.. however I repeatedly get exceptions such as:

"The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM,Basic realm="wss.internaldev.local"'.

Can anyone provide an example of connecting to a "remote" SharePoint web service with Windows credentials?

ListsSoapClient proxy = new ListsSoapClient();

proxy.ClientCredentials.Windows.ClientCredential.UserName = "admin_user";
proxy.ClientCredentials.Windows.ClientCredential.Password = "admin_password";
proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Identification;

listItems = proxy.GetListItems(...);

proxy.Close();

Binding examples:

<security mode="TransportCredentialOnly">
  <transport clientCredentialType="Windows" proxyCredentialType="None" />
</security>

or..

<security mode="TransportCredentialOnly">
  <transport clientCredentialType="Ntlm" />
</security> 

behaviour:

<behavior name="behavior_WSS">
  <clientCredentials>
    <windows allowedImpersonationLevel="Impersonation" allowNtlm="true" />
  </clientCredentials>
</behavior>

or

    <windows allowedImpersonationLevel="Delegation" allowNtlm="true" />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉酒的小男人 2024-07-30 12:04:43

您是否尝试过建议的内容这里

例如,在代码中:

proxy.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonation.Impersonate;
// AllowNtlm = false;

Did you try the things suggested here?

eg, in code:

proxy.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonation.Impersonate;
// AllowNtlm = false;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文