1

I want to implement User and Role Manager in VS 2015 using the Identity.EntityFramework": "3.0.0-rc1-final".

Among others I have created a class IdentityManager.

My main problem is creating a method to check the existence of a Role as follows.

public bool RoleExists(string name)
{
    var RoleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(new ApplicationDbContext()));

    return RoleManager.RoleExists(name);
} 

I keep getting the error on new RoleManager<IdentityRole>:

There is no argument given that corresponds to roleValidators, keyNormalizer, errors, logger,contextAccessor"

Yes, basically all the parameters I am not specifying but I have no idea how to approach these.

I am very new at this and have been searching and trying for days now, if someone can just point me in the right direction I am willing to do the legwork and testing, I just need some documentation.

DavidG
  • 113,891
  • 12
  • 217
  • 223
JCarstens
  • 11
  • 2

1 Answers1

1

I am having a similar issue - it looks like the roles are not the best option in identity 3.0

This thread (ASP .NET 5 MVC 6 Identity 3 Roles Claims Groups) helped me get something working, but its sad that this is not better documented.

Here are my attempts at improving that. Asp.net.Identity (3.0.0.0-rc1-final)

in Startup.cs --> ConfigurationServices //Define your policies here, they are strings associated with claims types, that have claim strings... //they need to be in AspNetUserClaims table, user id, department, Dev to be allowed access to the Dev policy //add the auth option, below that makes it work, and in the api controller, add the
//[Authorize("Dev")] attribute //services.AddAuthorization( // options => // { // options.AddPolicy("Dev", policy => { policy.RequireClaim("department", "Dev"); }); // });

Community
  • 1
  • 1
flagman
  • 29
  • 4