开发者

WCF PrincipalPermission Attribute Exception loggin

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.

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.

开发者_Go百科Does anyone have a good idea of how to achieve this.


Two suggestions for you:

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

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜