使用WCF连接并验证SharePoint

mis*_*dan 12 sharepoint wss web-services windows-authentication

我对这一个很疯狂,无论如何都找不到任何体面的信息.

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

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

我尝试了许多组合,如下面的代码..但是我反复得到例外:

"HTTP请求未经授权使用客户端身份验证方案'匿名'.从服务器收到的身份验证标头是'NTLM,Basic realm ="wss.internaldev.local"'.

任何人都可以提供使用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();
Run Code Online (Sandbox Code Playgroud)

绑定示例:

<security mode="TransportCredentialOnly">
  <transport clientCredentialType="Windows" proxyCredentialType="None" />
</security>
Run Code Online (Sandbox Code Playgroud)

要么..

<security mode="TransportCredentialOnly">
  <transport clientCredentialType="Ntlm" />
</security> 
Run Code Online (Sandbox Code Playgroud)

行为:

<behavior name="behavior_WSS">
  <clientCredentials>
    <windows allowedImpersonationLevel="Impersonation" allowNtlm="true" />
  </clientCredentials>
</behavior>
Run Code Online (Sandbox Code Playgroud)

要么

    <windows allowedImpersonationLevel="Delegation" allowNtlm="true" />
Run Code Online (Sandbox Code Playgroud)

Che*_*eso 1

您尝试过这里建议的事情吗?

例如,在代码中:

proxy.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonation.Impersonate;
// AllowNtlm = false;
Run Code Online (Sandbox Code Playgroud)