1

I need to be able to access CRUD operations on the users in a system using ASP.NET Web API 2 using ASP.NET Identity. Via the API, I would like to list all users in the system, and allow the API to modify, delete and add new users to the system. Can someone provide me with some direction on how this would be accomplished?

Thanks!

Bob
  • 97
  • 10
  • 3
    have you tried anything? Any code? maybe a blog or a codeproject post? – Aniket Inge Sep 11 '14 at 12:53
  • 1
    User management through WebApi is not much different from MVC. Identity framework is not coupled with MVC framework, so take sample from MVC and convert it to WebApi. – trailmax Sep 11 '14 at 13:03

2 Answers2

1

You can expose all the functions of the UserStore via your webapi and that would get you a long way toward what you are describing. For the functions it does not provide, you are responsible for instantiating the IdentityDbContext to the UserStore so you can using for whatever you like including listing all users, organizing by roles and so on that an admin interface would require.

I actually implemented a UserStore that called a webapi wrapped UserStore via http to preserve a clients layered architecture. Not difficult at all to do.

Here is a link that discusses more about using IdentityDbContext directly. Why is Asp.Net Identity IdentityDbContext a Black-Box?

Community
  • 1
  • 1
Philip Nelson
  • 985
  • 6
  • 20
1

You can expose or create new end points which are responsible for the CRUD operations against the users, you can check this post as it shows how to register (add) new users so you will get the idea how to complete the rest operations. http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/

Taiseer Joudeh
  • 8,953
  • 1
  • 41
  • 45