Hi I'm using WSE 3.0 with a Custom UsernameTokenManager ah la the
username authentication sample - now it all works as expected, however
I would now like to "take it up a notch" and introduce roles... I have
custom roles for each user stored in the database (as well as the users
themselves) - however I'm not sure how I should expose these roles to
WSE 3.0.
I set up a restriction within a policy so that all users had to be
within a certain Role, which did stop any users being able to
authenticate at all against my service, so the policy works :) but
without being able to expose my applications roles to WSE this isn't
very helpful.
I'm sure this can't be too difficult, can anyone offer suggestions (my
service is exposed via soap.tcp, so there's no asp.net involved, just
windows services).
Cheers,
- Alex
Pablo Cibraro - 10 Nov 2005 15:11 GMT
Hi Alex,
You have to create a principal with your custom roles. The code below shows
how to do that:
protected override string AuthenticateToken( UsernameToken token )
{
bool validCredentials = Membership.ValidateUser(token.Username,
token.Password);
if (!validCredentials)
{
throw new ApplicationException("Authentication error");
}
GenericIdentity identity = new GenericIdentity(token.Username);
GenericPrincipal principal = new GenericPrincipal(identity,
Roles.GetRolesForUser(token.Username));
token.Principal = principal;
return token.Password;
}
Regards,
Pablo Cibraro
http://weblogs.asp.net/cibrax
http://www.lagash.com
> Hi I'm using WSE 3.0 with a Custom UsernameTokenManager ah la the
> username authentication sample - now it all works as expected, however
[quoted text clipped - 16 lines]
>
> - Alex