为什么 IpcChannel 告诉我“无法打开匿名级别安全令牌?”
我有一个非常简单的客户端-服务器应用程序,我用它来分隔两个不能在同一进程中共存的组件。 当开发它们时(服务器是一个exe,客户端是一个库),我所有的单元测试都像粪肥里的猪一样快乐。 当我继续在其他地方重用该库时,出现以下异常:
System.Runtime.Remoting.RemotingException: An error occurred while processing the request on the server: System.Security.SecurityException: Cannot open an anonymous level security token.
at System.Security.Principal.WindowsIdentity.GetCurrentInternal(TokenAccessLevels desiredAccess, Boolean threadOnly)
at System.Security.Principal.WindowsIdentity.GetCurrent()
at System.Runtime.Remoting.Channels.Ipc.IpcServerTransportSink.ServiceRequest(Object state)
The Zone of the assembly that failed was:
MyComputer.
为了简单起见,我已在代码中设置了双方的远程处理,而不是配置文件。 它们实际上是相同的:
BinaryClientFormatterSinkProvider client = new BinaryClientFormatterSinkProvider();
BinaryServerFormatterSinkProvider server = new BinaryServerFormatterSinkProvider();
server.TypeFilterLevel = TypeFilterLevel.Full;
Hashtable config = new Hashtable();
config["name"] = "SomeName";
config["portName"] = "SomePortName";
config["typeFilterLevel"] = "Full";
config["impersonate"] = "true";
config["tokenImpersonationLevel"] = "Impersonation";
config["useDefaultCredentials"] = "True";
config["secure"] = "True";
Channel = new IpcChannel(config, client, server);
所以问题是:为什么远程框架要在启用模拟时创建匿名令牌? 我已经完全没有地方可以寻找这方面的答案了。
I have a pretty simple client-server app that I am using to separate two components that can't live together in the same process. When developing them (the server is an exe, the client is a library), all my unit tests are happy as pigs in manure. When I move on to re-using the library elsewhere, I get the following exception:
System.Runtime.Remoting.RemotingException: An error occurred while processing the request on the server: System.Security.SecurityException: Cannot open an anonymous level security token.
at System.Security.Principal.WindowsIdentity.GetCurrentInternal(TokenAccessLevels desiredAccess, Boolean threadOnly)
at System.Security.Principal.WindowsIdentity.GetCurrent()
at System.Runtime.Remoting.Channels.Ipc.IpcServerTransportSink.ServiceRequest(Object state)
The Zone of the assembly that failed was:
MyComputer.
I have set up the remoting on both sides in code, rather than config files for simplicity at this stage. They are effectively identical:
BinaryClientFormatterSinkProvider client = new BinaryClientFormatterSinkProvider();
BinaryServerFormatterSinkProvider server = new BinaryServerFormatterSinkProvider();
server.TypeFilterLevel = TypeFilterLevel.Full;
Hashtable config = new Hashtable();
config["name"] = "SomeName";
config["portName"] = "SomePortName";
config["typeFilterLevel"] = "Full";
config["impersonate"] = "true";
config["tokenImpersonationLevel"] = "Impersonation";
config["useDefaultCredentials"] = "True";
config["secure"] = "True";
Channel = new IpcChannel(config, client, server);
So the question is: Why would the remoting framework want to create an anonymous token when impersonation is enabled? I've completely run out of places to look for answers on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是答案
我知道这是一个老问题,但也许有人找到了解决方案。 我的设置与作者类似,但只需要标识级别:
服务器端:
客户端:
然后间歇性地得到以下信息:
在服务器上处理请求时发生错误:System.Security.SecurityException:无法打开匿名级别安全令牌。
位于 System.Security.Principal.WindowsIdentity.GetCurrentInternal(TokenAccessLevelsdesiredAccess, Boolean threadOnly)
at System.Security.Principal.WindowsIdentity.GetCurrent()
at System.Runtime.Remoting.Channels.Ipc.IpcServerTransportSink.ServiceRequest(Object state)
失败的程序集的区域是:
我的电脑
IT'S NOT AN ANSWER
I know it's an old question but maybe someone found a solution. I have similar setup to author's, but only identification level is required:
Server side:
Client side:
And then intermittently I get the following:
An error occurred while processing the request on the server: System.Security.SecurityException: Cannot open an anonymous level security token.
at System.Security.Principal.WindowsIdentity.GetCurrentInternal(TokenAccessLevels desiredAccess, Boolean threadOnly)
at System.Security.Principal.WindowsIdentity.GetCurrent()
at System.Runtime.Remoting.Channels.Ipc.IpcServerTransportSink.ServiceRequest(Object state)
The Zone of the assembly that failed was:
MyComputer