これに似た SO に関する質問がたくさんあることは知っていますが、この特定の問題に関する質問は見つかりませんでした。
最初にいくつかのポイント:
- 私は、Sharepoint サーバーを制御できません。IIS 設定を微調整できません。
- IIS サーバーのバージョンは IIS 7.0 だと思います。
- Sharepoint Server は NTLM 経由のリクエストを予期しています。
- Sharepoint Server は、クライアント コンピューターと同じドメインにあります。
- .NET Framework 3.5、Visual Studio 2008 を使用しています
Sharepoint Web サービスを使用して SharePoint データを操作する単純なコンソール アプリを作成しようとしています。サービス参照を追加しました。以下は app.config です。
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ListsSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://subdomain.companysite.com/subsite/_vti_bin/Lists.asmx"
binding="basicHttpBinding" bindingConfiguration="ListsSoap"
contract="ServiceReference1.ListsSoap" name="ListsSoap" />
</client>
</system.serviceModel>
これは私のコードです:
static void Main(string[] args)
{
using (var client = new ListsSoapClient())
{
client.ClientCredentials.Windows.ClientCredential = new NetworkCredential("username", "password", "domain");
client.GetListCollection();
}
}
GetListCollection() を呼び出すと、次のMessageSecurityExceptionがスローされます。
The HTTP request is unauthorized with client authentication scheme 'Ntlm'.
The authentication header received from the server was 'NTLM'.
内部 WebException の場合:
"The remote server returned an error: (401) Unauthorized."
さまざまなバインディングとさまざまなコードの微調整を試みて、適切に認証しようとしましたが、役に立ちませんでした。以下にそれらをリストします。
次の手順を試しました。
クライアントを作成する前にネイティブの Win32 Impersonator を使用する
using (new Impersonator.Impersonator("username", "password", "domain"))
using (var client = new ListsSoapClient())
{
client.ClientCredentials.Windows.ClientCredential = new NetworkCredential("dpincas", "password", "domain");
client.GetListCollection();
}
これにより、同じエラー メッセージが生成されました。
クライアント資格情報の TokenImpersonationLevel の設定
using (var client = new ListsSoapClient())
{
client.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
client.GetListCollection();
}
これにより、同じエラー メッセージが生成されました。
セキュリティ モードの使用 = TransportCredentialOnly
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" />
</security>
これにより、別のエラー メッセージが表示されました。
The provided URI scheme 'https' is invalid; expected 'http'.
Parameter name: via
ただし、https を使用する必要があるため、URI スキームを変更できません。
覚えていない他の組み合わせをいくつか試しましたが、それらを投稿します。私は本当にここで機知に富んでいます。Google には「Kerberos に切り替える」というリンクがたくさんありますが、私のサーバーは「ネゴシエート」ではなく NTLM のみを受け入れているようです (Kerberos を探しているかのように)。残念ながらそれはオプションではありません。 .
皆さん、何か助けはありますか?