Enrico Tirotta
Enrico Tirotta

Reputation: 323

Manage Asp.net Identity users/roles inside project with Organization Account auth

I build a solution with some c# library for

There are also 2 main project :

  1. WebApp is a the startup project based on Asp.net Identity Auth (register functions, login etc..)
  2. Admin app, where organization manages and creates all contents (used & displayed by Webapp) and based on Organizational account auth (Azure Active Directory)

enter image description here

My problem: I need to manage users and roles in Admin App with UserManager/RoleManager (_Dati.Accesso.Identity library) but i haven't any OwinContext on current request because on admin app i don't create any owin pipeline in startup/configAuth methods.

What is the best way to solve the problem? I'm not very well versed with issues affecting auth logic. Is there a way to create an on-demand OWINcontext and create with it user/role manager? Or the solution is create a startup/configAuth method on Admin app too? ... or something else :) enter image description here

Thanks for your time.

Upvotes: 1

Views: 878

Answers (1)

m0s
m0s

Reputation: 4280

You don't have to have Owin context to manage accounts.

This should work:

 var dbContext=new ApplicationDbContext();// This is your IdentityDbContext
 var userManager=new ApplicationUserManager(new UserStore<ApplicationUser>(dbContext));

You will need a reference to your original project to have access to the ApplicationDbContext class, and you will need to configure the connection string properly so that your dbContext can connect to the database.

Upvotes: 1

Related Questions