1

Hoping someone can assist this has been a challenge. I am new to the Identity "way" of doing member login so please be patient.

  1. login, register all work fine
  2. when I login, I would like to see if the user is admin or not

    If Not Roles.IsUserInRole(User.Identity.Name, "admin") Then
            rUser.Text = "You are not authorized"
        Else
            rUser.Text = "WELCOME ADMIN"
        End If
    
  3. When I run the app, I get the error Screenshot of Error (not enabled)

I have looked at many articles and this should "just work". for some reason this just isn't working.

Using framework 4.5, VB.NET, VS 2013, built in IDENTITY.

ookie
  • 138
  • 11
  • Do you have it enabled in the web.config? – Aaron Oct 18 '15 at 03:52
  • I tried that, however through an error looking for aspnet_schemaversion stored procedure, but that is the old membership. this has been a 5 day whirlwind... from what I have seen and read, nothing needs to be set in the webconfig. I can login and create users with out membership provider. am I misunderstanding something? – ookie Oct 18 '15 at 03:55

1 Answers1

0

You need to make sure it's enabled in the web.config

<roleManager 
enabled="true" 
cacheRolesInCookie="true" >

The full details of the security in .net from MSDN

Aaron
  • 511
  • 3
  • 25
  • sqlserver to be exact – ookie Oct 18 '15 at 04:01
  • Are you not using a database for your membership? With regards to the aspnet_schemaversion proc. I remember having to grant explicit execute permissions to it for the user the membership and role provider was using to access the database. What version of the .net frameworks did you use to install the aspnet database with? – Aaron Oct 18 '15 at 04:11
  • I created a new project in VS 2013, registered a user and the database was created for me. dbo._MigrationHistory dbo.AspNetRoles dbo.AspNetUserClaims dbo.AspNeUserLogins dbo.AspNetUserRoles dbo.AspNetUsers – ookie Oct 18 '15 at 04:15
  • What is in your web config for the membership database? Is it all being driven by the machine.config? – Aaron Oct 18 '15 at 04:16
  • Nothing set in web.config. where would i find machine.config? – ookie Oct 18 '15 at 04:17
  • Windows installation path\Microsoft.NET\Framework\v4.0.30319\ – Aaron Oct 18 '15 at 04:30
  • Nothing, a little frustrating :s – ookie Oct 18 '15 at 04:36
  • I don't have a machine config in front of me but if I recall the membership provider had a default connection string to the local hosts SQL express but the role manager wasn't actually defined to be enabled or with a default connection string – Aaron Oct 18 '15 at 04:40
  • Should this not define my application connString ' Public Class ApplicationDbContext Inherits IdentityDbContext(Of ApplicationUser) Public Sub New() MyBase.New("connString", throwIfV1Schema:=False) End Sub Public Shared Function Create As ApplicationDbContext Return New ApplicationDbContext() End Function End Class' Found in the identityModels.vb – ookie Oct 18 '15 at 04:48