Roles from Policy

Roles from Policy

Post by SWx2e » Thu, 19 Aug 2004 17:07:02

Is there some way that I can retrieve the roles of my webservice in my custom
UsernameTokenManager from policy?
I defined all the roles in policy and I can retrieve all the roles that the
person is in who is calling the webservice. Now I'd like to know which roles
you have to be in to access the webservice :)
Because I defined them in policy, I want to prevent having to copy paste
them in my code, and prefer to access policy programmaticly in some way
unknown to me :)


Roles from Policy

Post by HongMei G » Fri, 20 Aug 2004 14:14:06


You can try to retrieve this role information from the
LoadSecurityTokenAssertion method in your customized UsernameTokenManager.

public class MyUsernameTokenManager: UsernameTokenManager {
public override ISecurityTokenAssertion
LoadSecurityTokenAssertion(XmlElement element)


/* parse the element to get the role element

this element should look like

<SecurityToken xmlns=" ">

<wssp:UsePassword wsp:Usage="wsp:Rejected" />



// Do not foget to invoke the base class

return base.LoadSecurityTokenManager(element);



Hope this helps.




Roles from Policy

Post by SWx2e » Fri, 20 Aug 2004 21:27:02


Thanks a lot!! I wasn't sure on how to use that method, or what it was for
;D even though I looked up all the SecurityTokenManager methods. But this was
exactly the information that I needed! Thanks!!!