0

I am working on User management for my site.

1) I have created a VB.net webforms application in Visual Studio 2013.

2) I ran the site

3) registered a user

4) logged in using that user and all is great.

However, when I tried to display a message to see if the user was in admin role using

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    If Not Roles.IsUserInRole(User.Identity.Name, "admin") Then
        rUser.Text = "You are not authorzied"
    Else
        rUser.Text = "WELCOME ADMIN"
    End If
End Sub

I get the following error when trying to login. If I understand correctly, this is the old Membership Store Procedure that it is trying to find. I have been looking for a couple of days and can't seem to figure out what is going on. everything I see seems to "just work".

I know it's rude to point but if someone could point me in the right direction. I have a feeling it's some simple...

Schema Error Image

NOTE: Just saw this one https://stackoverflow.com/q/29392043/3884800 apparently this is not an easy one... :S

UPDATE: getting new error:

Roles not enabled

Am I missing something in the App_Start???

Community
  • 1
  • 1
ookie
  • 138
  • 11

1 Answers1

0

Identity has own Role Manager therefor Roles class dose not work when using Identity. So if you want check if a user in role or not simply write something like this:

To check current user use:

User.IsInRole("Admin")

To check another user:

Dim manager = Context.GetOwinContext().GetUserManager(Of ApplicationUserManager)()
manager.IsInRole("UserID", "Admin")
Sam FarajpourGhamari
  • 14,601
  • 4
  • 52
  • 56
  • YAAAAHOOOOO!!!! Many many thank you's you rock. I have been struggling with this for some time.. many thanks @Sam Farajpour Ghamari – ookie Oct 22 '15 at 15:47