WCF属性的PrincipalPermission洛异常 [英] WCF PrincipalPermission Attribute Exception loggin

查看:174
本文介绍了WCF属性的PrincipalPermission洛异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与他们的属性的PrincipalPermission方法WCF服务。如果不具备适当权限的用户尝试访问该属性抛出一个SecurityException但由于异常的属性抛出这是不可能把try..chatch呼叫周围的那些方法。

I have a WCF service that has methods with the PrincipalPermission attribute on them. When a user that does not have the appropriate permissions tries to access those methods the attribute throws a SecurityException but since the exception is thrown in the attribute it's not possible to put try..chatch around the call.

我已经使用从企业库用记录处理程序ExceptionShielding属性尝试,但它并没有写任何日志。我甚至尝试写一个WCF行为扩展,试图捕捉异常,但延长不能正确调用异常处理块。

I have tried using the ExceptionShielding attribute from the Enterprise Library with a logging handler but it does not write any logs. I even tried writing a WCF Behavior extension to try and catch the exception but the extension could not call the exception handling block properly.

有没有人对如何是个好主意。实现这个

Does anyone have a good idea of how to achieve this.

推荐答案

你两个建议:

1)切换到使用新的PrincipalPermission(...),需求()替代属性。

1) Switch to using new PrincipalPermission(...).Demand() instead of the attribute.

2)取一看这里在评论(#5我认为) 。忽略所提供的代码存在的链接 - 代码是在这里上的谷歌代码。尼克·贝拉尔迪创造了一个ExceptionHandlerAttribute把指定的异常转换成网页的响应。现在,这并不完全匹配您的方案,但他的课必须是醒目的属性的PrincipalPermission抛出的异常,所以也许你可以使用相同的本金。

2) Take a look here in the comments (#5 I think). Ignore the link provided to the code there - code is here on Google Code. Nick Berardi has created an ExceptionHandlerAttribute to turn specified exceptions into web responses. Now this doesn't quite match your scenario, but his class must be catching the Exception thrown by the PrincipalPermission attribute, so maybe you can make use of the same principal.

这篇关于WCF属性的PrincipalPermission洛异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆