我需要我的自定义 MembershipProvider 在 ValidateUser 上引发异常
我创建了一个自定义成员资格提供程序,该提供程序现在正在生产中正常工作,可以很好地验证我的 WCF 调用。
我确实时不时地遇到一个问题,由于某种未知的原因,我的提供商无法验证用户。在这些情况下,我不希望 ValidateUser 函数只返回 false,因此我想到了抛出和异常,并提供更多帮助(不是太多,只是一点点)。
我的问题是,即使我抛出 ProviderException ,客户端总是会得到一个 MessageSecurityException ,没有任何有用的信息......只是好老:
“从另一方收到不安全或不正确的安全故障。请参阅内部的FaultException以了解故障代码和细节。”
“验证消息的安全性时发生错误。”在内。
如何获取我在自己的 ValidateUser 方法中抛出的消息?自定义行为怎么样?
提前致谢
I created a custom Membership Provider which is now working in production just fine validating my WCF calls.
I do have an issue every now and then that for some unknown reason my provider cannot validate the user. In those cases I do not want the ValidateUser function to just return false, so I thought of throwing and excception with a little more help (not too much, just a little).
My problem is, even though I am throwing a ProviderException the client always gets a MessageSecurityException with no helpful info... just the good old:
"An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail."
with "An error occurred when verifying security for the message." in the Inner.
How can I get the message I am throwing in my own ValidateUser method? what about a custom behavior?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现这篇文章引导我找到了解决方案,我不确定这是否是正确的举动
从 WCF UserNamePasswordValidator 正确捕获 SecurityTokenException
基本上我必须抛出 FaultException 我对此不太高兴,因为我的会员提供程序实现与 WCF 无关(或者至少到目前为止),现在它知道了 FaultExceptions :(
有更好的解决方案吗?
I found this post that led me to a solution, I'm not sure if it is the right move
Properly catch SecurityTokenException from a WCF UserNamePasswordValidator
Basically I have to throw a FaultException which I'm not really happy abou because my Membership Provider implementation is WCF agnostic (or at least was until now) now it knows about FaultExceptions :(
Is there a better solution out there?