WCFサービスと偽装に関するいくつかの問題がありますが、これを以下の簡単な方法で掘り下げました。 WCFサービスは、現在、exeで自己ホストされています。例外メッセージは、「必要な偽装レベルが提供されていないか、または提供された偽装レベルが無効です」です。エラーがスローされたことを確認すると、Identity ImpersonationLevelは、クライアント上で指定された委譲に設定され、Kerberosを通じて認証されます。必要な偽装レベルが提供されていないか、または提供されている偽装レベルが無効です
私は、ImpersonationLevelとAuthenticaitonの要件が満たされているように思えるので、少し混乱します。私の考えは、おそらく問題はおそらく私が設定し、正しく設定されていると思うドメイン設定と関係しているということです。だから私は2つの質問があります:
- 以下の操作は成功するはずですか? (またはそれに欠陥がありますか?)
- Win2k8ドメインではどのような設定を行う必要がありますか?私は同じWin2k8ドメインのメンバである2つのボックス(その新しいドメインとかなりのバニラ、偽装をテストする意図を持っている)の作業をしています。
コードは次のように:
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public string Test()
{
WindowsIdentity identity = ServiceSecurityContext.Current.WindowsIdentity;
using (identity.Impersonate())
{
ProcessStartInfo pi = new ProcessStartInfo(@"c:\temp\test.bat");
pi.UseShellExecute = false;
pi.RedirectStandardOutput = true;
Process p = Process.Start(pi); // exception thrown here!
p.WaitForExit();
string o = p.StandardOutput.ReadToEnd();
return o;
}
}
例外の詳細:
Win32Exception occurred: Either a required impersonation level was not provided, or the provided impersonation level is invalid
at System.Diagnostics.Process.CreatePipeWithSecurityAttributes(SafeFileHandle& hReadPipe, SafeFileHandle& hWritePipe, SECURITY_ATTRIBUTES lpPipeAttributes, Int32 nSize)
at System.Diagnostics.Process.CreatePipe(SafeFileHandle& parentHandle, SafeFileHandle& childHandle, Boolean parentInputs)
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at MonetEnterprise.Service.SecurityService.Test()
TEST.BATファイルの内容
をエコー%のユーザ名%
デバッガを使用する前に 'identity'が' using'ブロックに入るのは同じですか? –
こんにちは@Rahmhound、それはクライアントのログオンです - それはあなたが期待するものですか? –
NTドメインでは、委任はデフォルトで無効になっています。必要であれば(そうであるように)、それを有効にする必要があります。 [制約付き委任の有効化](http://technet.microsoft.com/en-us/library/cc756940(V= ws.10).aspx)または[制限付き委任を使用したマルチホップ偽装を有効にする方法については、 Active Directory](http://www.codeproject.com/Articles/38979/How-to-enable-multi-hop-impersonation-using-constr) –