現在、クレーム対応のSharePoint2010サイトに展開されているWCFサービスがあります。WCFサービスは特別なものではなく、提供されているMicrosoft.SharePoint.Client.Services.MultipleBaseAddressBasicHttpBindingServiceHostFactoryをWCFサービスファクトリとして使用します。したがって、ファクトリから提供されている、すぐに使用できるBasicHttpBindingを使用しています。
私のクライアントapp.configは次のようになります。
<configuration>
<system.serviceModel>
<bindings>
<binding name="BasicHttpBinding_MyServices" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="200524288" maxBufferPoolSize="200524288" maxReceivedMessageSize="200524288"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</bindings>
<client>
<endpoint address="http://localhost/_vti_bin/MyServices/MyService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_MyServices"
contract="ServiceClient.MyService.IMyService"
name="BasicHttpBinding_IMyService" />
</client>
</system.serviceModel>
</configuration>
私のThread.CurrentPrincipal.Identityを見ると、それは正しいです。これは、現在実行中のユーザーとのClaimsIdentityです。その後、SPUserTokenを作成または利用しなくても、新しいSPSiteインスタンスを開くことができます。
注意すべき重要な点の1つは、WCFサービスに接続する前に自分のIDを偽装しないことです。これが実行している場合、SharePointサーバーがクレームプロバイダーとの信頼関係を確立していない限り、機能しない可能性があります。