Web system accessed by several companies appsettings

2

I'm developing an ASP.NET Core application, where each company owns its database. The question is: how can I do for the company to access the site by putting user and password and access information of it, remembering that there are several companies? Is there a way to change appsettings.config to this, another alternative?

I've been seeing the question Databases for Different Clients , it would not be the right thing to do.

    
asked by anonymous 01.05.2017 / 07:56

2 answers

0
  

I've been seeing the question Databases for Different Clients , it would not be the right thing to do.

It depends. If you want to separate the databases by company, it is, but it does not seem to be your case.

I'm assuming you're using ASP.NET Core Identity . That being the case, you need to be familiar with the claims / a>, that is, of portions of identity that your user has.

To add a claim to your user, you can use:

await userManager.AddClaimAsync(user, new System.Security.Claims.Claim("empresa", "A"));

Or:

usuario.Claims.Add(new IdentityUserClaim<string> 
{ 
    ClaimType = "empresa", 
    ClaimValue = "A" 
});

contextoIdentity.Entry(usuario).State = EntityState.Modified;
await contextoIdentity.SaveChangesAsync();

Or this answer here . Whatever.

If it is very necessary for you to change the database,

01.05.2017 / 09:00
1

One of the solutions is to model the bank containing the foreign keys for the companies.

Ex: You have the user "John" with the foreign key for company "X", as soon as "John" accesses the system you will know that it should show company information "X", this is valid for other entities of the system.

    
01.05.2017 / 08:10