我必须将RPC_C_IMP_LEVEL_IMPERSONATE
设置为powershell进程。你知道我怎么能做到这一点吗?
我只找到this信息。它是关于通过CoInitializeSecurity
使用C ++更改默认模拟级别。但遗憾的是,我无法将其用于powershell
。它需要main
函数。
/// <summary>
/// The main entry point for the application.
/// Do not set STAThread since CoInitializeSecurity is called
/// with to high security automatically (and it can only be called once).
/// </summary>
//[STAThread]
static void Main()
{
// Set threading apartment
System.Threading.Thread.CurrentThread.ApartmentState = ApartmentState.STA;
CoInitializeSecurity( IntPtr.Zero, -1, IntPtr.Zero,
IntPtr.Zero,RpcAuthnLevel.None ,
RpcImpLevel.Impersonate,IntPtr.Zero, EoAuthnCap.None, IntPtr.Zero );
Application.MainForm = new MainForm();
System.Windows.Forms.Application.Run(Application.MainForm);
}
我有一个客户端(powershell
)和服务。我不能打电话给服务,因为它给了我以下错误:
Either a required impersonation level was not provided, or the provided impersonation level is invalid.
我在*.log
中发现当前的假冒等级为Identification
。