WCF:GetRolesForUser 在哪里?我看到的只是 GetRolesForCurrentUser
当我通过继承 RoleProvider 创建自定义角色提供程序时,我创建了一个方法 称为 public override string[] GetRolesForUser(string username) ..但是,当我尝试 要使用此服务引用,我只能访问 GetRolesForCurrentUser()。有用 并在幕后调用我的方法即可。如所示,GetRoleseForCurrentUser 传递当前 用户使用我的方法,所以一切都很好。但我想知道的是,有没有办法让我 还暴露了我原来的方法(带有参数的方法),或者我错过了什么?
When I create a custom role provider by inheriting from RoleProvider, I created a method
called public override string[] GetRolesForUser(string username) .. However, when I try
to use this Service Reference all I have access to is GetRolesForCurrentUser(). It works
and calls my method behind the scenes ok. As in, GetRoleseForCurrentUser passes the current
user into my method so it's all good. But what I'm wondering is, is there a way for me to
also expose my original method (the one that takes an argument), or am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,首先我必须假设一些东西,您正在使用用户名/密码消息层身份验证,以及用于消息层授权的自定义角色提供程序。
GetRolesForCurrentUser() 的要点是它检查当前线程的主要用户并返回该用户的所有角色,这样用户就永远无法冒充其他人。用户名/密码必须嵌入到消息标头中,当您在客户端上设置代理凭据时,这会在 .net 中自动发生。
如果允许调用 WCF 客户端的用户将其用户名作为参数传递,则意味着角色提供程序设计仍将通过当前线程主体用户对用户进行身份验证,然后您希望通过传递的用户名进一步对用户进行身份验证对于 GetRolesForUser(string username),除了某种复杂的模拟方案之外,没有任何意义。
如果这是您的目标,请查看此链接
Well, first off i have to assume some stuff, you are using Username/Password message layer authentication, and a custom role provider for the message layer authorization.
The point of GetRolesForCurrentUser() is that it checks the current threads Principal user and returns all roles for that user, in that way the user can never impersonate somebody else. The Username/Password must be embedded into the Message headers, this happens automatically in .net when you set the proxy Credentials on the client.
If the user calling the WCF client was allowed to pass his Username as a parameter, it means the role provider by design will still authenticate the user by the current threads Principal user and then you would want to authenticate further the user by the the Username passed to GetRolesForUser(string username), there is no point, besides some kind of complicated impersonation scheme.
If that is you goal, check out this link