This is a migrated thread and some comments may be shown as answers.

ASP.NET Identity 2.x provider

4 Answers 130 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Fredrik
Top achievements
Rank 2
Fredrik asked on 21 Oct 2014, 09:14 PM
I recently migrated one of my projects to Data Access and needed to get a solution for authentication that was as flexible. So I decided to create a Data Access implementation for ASP.NET Identity 2.x. Just wanted to share it with anyone else that can find it useful. Code feedback are also very welcomed :)

The code can be found at: https://github.com/fschultz/AspNet.Identity.DataAccess/

4 Answers, 1 is accepted

Sort by
0
Boyan
Telerik team
answered on 24 Oct 2014, 11:39 AM
Hello Fredrik,

We are very thankful for your input. Could I kindly ask you to provide a short description or a simple sample project that demonstrate how your implementation is designed to be used with an ASP application? I had some trouble integrating it following an approach similar to the one described in this documentation article.

I am looking forward to hearing from you.

Regards,
Boyan
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Fredrik
Top achievements
Rank 2
answered on 24 Oct 2014, 06:50 PM
I've posted an article on how to convert from the standard Entity Framework implementation that's added when creating a templated ASP.NET web project: http://kaliko.com/blog/aspnet-template-for-data-access-identity/

I noticed that it's requires a few more steps than the MySQL implementation to get it up and running with the sample code that comes with the templated web project. Much due to the fact that I chose to use Guids as identifiers rather than strings which require the identifier data type to be specified in many calls.

General usage is much more straight forward, the following sample creates a role if it not exist and assign a user to it:
using AspNet.Identity.DataAccess;
using Microsoft.AspNet.Identity;
 
...
 
var roleManager = new RoleManager<IdentityRole, Guid>(new RoleStore());
 
var roleName = "MyGroup";
 
var role = roleManager.FindByName(roleName);
 
if (role == null) {
    role = new IdentityRole(roleName);
    roleManager.Create(role);
}
 
var userManager = new UserManager<IdentityUser, Guid>(new UserStore());
 
var user = userManager.FindByName("MyUser");
 
if (user != null) {
    userManager.AddToRole(user.Id, roleName);
}
0
Boyan
Telerik team
answered on 29 Oct 2014, 04:38 PM
Hello Fredrik,

We much appreciate your contribution to the Telerik Data Access community. 

Please find your Telerik Points for your great help.

Regards,
Boyan
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Boyan
Telerik team
answered on 29 Oct 2014, 04:40 PM
Hello Fredrik,

We much appreciate your contribution to the Telerik Data Access community. 

Please find your Telerik Points for your great help.

Regards,
Boyan
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
General Discussions
Asked by
Fredrik
Top achievements
Rank 2
Answers by
Boyan
Telerik team
Fredrik
Top achievements
Rank 2
Share this question
or