p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Professional (http://p2p.wrox.com/forumdisplay.php?f=215)
-   -   Forms Auth and Roles (http://p2p.wrox.com/showthread.php?t=46812)

~Bean~ August 22nd, 2006 09:51 AM

Forms Auth and Roles
 
I use Forms authentication in my project, I had no problems with it when my project was in 1.x, but since I moved it to 2.0 I am having trouble validating users in roles...they all come up as Authenticated, but false when I look at User.IsInRole("rolename")...is there a way to list out all the roles that a User is in?

-------------------------
Beware of programmers with screwdrivers...

~Bean~ August 22nd, 2006 11:35 AM

I found my own answer here:
http://msdn.microsoft.com/library/de...SecNetHT04.asp

Code:

Dim cookieName As String = FormsAuthentication.FormsCookieName
        Dim authCookie As HttpCookie = Context.Request.Cookies(cookieName)
        Dim authTicket As FormsAuthenticationTicket = Nothing
        authTicket = FormsAuthentication.Decrypt(authCookie.Value)
        Dim roles As String() = authTicket.UserData.Split(New Char() {"|"c})
        For Each r As String In roles
            Response.Write("arrayval=" & r & "<br />")
        Next

-------------------------
Beware of programmers with screwdrivers...


All times are GMT -4. The time now is 07:54 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.