Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / November 2005

Tip: Looking for answers? Try searching our database.

roles auth with a custom username token manager.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dnwo - 09 Nov 2005 07:55 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.