Solved

How to find user role with IdentityHelper, then redirect

Posted on 2015-02-02
2
412 Views
Last Modified: 2015-02-23
How do I find the role the user belongs to then redirect to a page in the Admin folder if they belong to the Admin role.


    Protected Sub LogIn(sender As Object, e As EventArgs)
        If IsValid Then
            ' Validate the user password
            Dim manager = New UserManager()
            Dim user As ApplicationUser = manager.Find(UserName.Text, Password.Text)
            If user IsNot Nothing Then
                IdentityHelper.SignIn(manager, user, RememberMe.Checked)
                IdentityHelper.RedirectToReturnUrl(Request.QueryString("ReturnUrl"), Response)
            End If
        Else
            FailureText.Text = "Invalid username or password."
            ErrorMessage.Visible = True
        End If
        End If
    End Sub

Open in new window

0
Comment
Question by:rrhandle8
2 Comments
 
LVL 8

Expert Comment

by:Naitik Gamit
ID: 40585596
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 40585906
You should be able to use something along the lines of:
Dim inRole As Boolean = UserManager.IsInRole(user.Id, "Admin")

Open in new window

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question