Web 服务-PrincipalPermission(SecurityAction.Demand)
出于概念证明和学习目的,我尝试对 SecurityAction.Demand 进行最简单的使用,如下所示:
[PrincipalPermission(SecurityAction.Demand, Role = @"MyDomain\MyGroup")]
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
我编写了一个控制台测试程序,并且我得到了 System.ServiceModel.Security.SecurityAccessDeniedException,即使我我是上面指定的组的成员。
我读过很多文档和博客,它们让我完全困惑。我似乎迷失在要尝试的事物的排列数量中。
问题:
我是否需要发布到 IIS,而不是在 Visual Studio 中使用 Cassini?
它仅适用于 wsHttpBinding 吗?我创建了一个 .NET 控制台测试程序,添加了一个服务引用,它默认为 basicHttpBinding,尽管我正在查看的一些博客和示例表明服务引用应该是 wsHttpBinding。
要使其正常工作,需要对绑定文件进行最少的更改。我知道必须更改一些参数才能将安全模式设置为 Windows,但首先我需要确保我处于正确的绑定中(因此是上面的问题 #2)。
For proof of concept and learning purposes, I'm trying to do the most simple possible use of SecurityAction.Demand as follows:
[PrincipalPermission(SecurityAction.Demand, Role = @"MyDomain\MyGroup")]
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
I wrote a console test program, and I'm getting the System.ServiceModel.Security.SecurityAccessDeniedException, even though I'm a member of the group specified above.
I've read a lot of docs and blogs which have left me totally confused. I seem to be getting lost in the number of permutations of things to try.
Questions:
Do I need to publish to IIS instead of using Cassini inside Visual Studio?
Does it work only with wsHttpBinding? I created a .NET console test program, added a service-reference and it defaulted to basicHttpBinding, even though some blogs and examples I was looking indicated that a Service Reference should be wsHttpBinding.
What are the minimum changes to the binding file to get this to work. I know have to change some parms to set security mode to Windows, but first I need to make sure I'm in the proper bindings (thus question #2 above).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论