C# 未提供所需的模拟级别,或者提供的模拟级别无效
我在WCF服务和模拟方面遇到了一些问题,我将其提炼为下面的一个简单方法。WCF服务当前在exe中自托管。异常消息为“未提供所需的模拟级别,或者提供的模拟级别无效”。检查抛出错误时,Identity ImpersonationLevel设置为delegation,这是在我的客户端上指定的,并通过Kerberos对其进行身份验证 我有点困惑,因为在我看来,模拟级别和身份验证的要求已经满足了。我的想法是,问题可能与域设置有关,我已经设置并认为设置正确。所以我有两个问题:C# 未提供所需的模拟级别,或者提供的模拟级别无效,c#,wcf,impersonation,windows-security,C#,Wcf,Impersonation,Windows Security,我在WCF服务和模拟方面遇到了一些问题,我将其提炼为下面的一个简单方法。WCF服务当前在exe中自托管。异常消息为“未提供所需的模拟级别,或者提供的模拟级别无效”。检查抛出错误时,Identity ImpersonationLevel设置为delegation,这是在我的客户端上指定的,并通过Kerberos对其进行身份验证 我有点困惑,因为在我看来,模拟级别和身份验证的要求已经满足了。我的想法是,问题可能与域设置有关,我已经设置并认为设置正确。所以我有两个问题: 下面的操作是否成功?(还是有缺
[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文件内容
回显%username%
这解决了我的应用程序的问题:
IIS\u IUSRS
来源:使用调试器在进入
使用
块之前,identity
等于什么?Hi@rahmhund,这是客户端的登录-这是您期望的,对吗?默认情况下,NT域中禁用委派。如果是必需的(看起来是),则必须启用它。看到或