Is it ok to delete records from ASP.NET identity tables AspNetUSers, AspNetRoles and AspNetUserRoles directly from SQL Server using T-SQL? The ASP.NET Core app is using only these three identity tables other AspNet... tables are empty.
UPDATE:
Why we want to do it directly through T-SQL since app has several users (with one role) and client wants to get rid of all the users quickly in one shot.
It is ok to delete rows from AspNetUsers, AspNetRoles or AspNetUserRoles.
Because IdentityServer does the same.
For example check the SQL statements which are generated when deleting a user through the UserStore class.
Related
I have created a default ASP Net Core MVC web app with Individual User Accounts. I added a custom UserID INT field to the AspNetUsers table and linked this as a foreign key to all my other custom tables so I can track what users inserted/updated records in my database. I did this as I prefer using INT fields for primary keys. In this scenario everything is working fine.
I am now thinking of using an external identity provider such as Azure Active Directory however I cannot work out how I would link a user in Azure AD (or any other identity provider) to my local database tables to maintain the user id foreign key constraints. From all my research I cannot find any articles for this scenario.
How can I link user info from an external identity provider to my local database tables? I am worried that I might need to double handle the user account management in both the external identity provider and my local AspNet user tables to maintain the foreign keys with my other custom tables which seems crazy.
Perhaps i'm missing something obvious or my approach is all wrong so if there is a better alternative for tracking who did what in my database tables for an ASP Net Core web application using an external identity provider I would happily adopt it.
There is no need to additional steps to link the user info for the user from external identity provider. It should looks be same for the web app.
When the users login from external identity provider, it still require to register the users to bind the user with individual accounts. The only difference is that there is no password for this kind of individual account and it can match the record in the AspNetUserLogins. Here are two accounts, one is binding to the external identity provider and the other is not:
I have an ASP.NET MVC 5 web app. I have connected to a database on localDB ("MyWebAppDatabase"), which already contains many tables. I am accessing this using ADO.NET Entity Framework, and this is all working great.
However, I would like to add a table which references users who use the website: I have a "Subscription" table and would like to associate it with an ApplicationUser. The problem is that the tables containing user information are stored in a separate database (which was automatically generated by the Visual Studio when I created the project under the DefaultConnection context), and I don't know how I can perform this association.
What is the best way to go about this? I thought the ideal solution would be if I could move the tables that ASP.NET automatically created for application users into MyWebAppDatabase - then I can easily update the database with the correct tables and foreign keys. Is this correct? If so, how would I go about doing this? I'm not entirely sure where the database is for the application users (I couldn't decipher it from looking at Web.Config and reading the DefaultConnection connection string) and I don't really understand how I would be able to migrate the tables.
Thank you all for your help!
Ideally if you can move the tables into a single database you will get the best performance, otherwise you will have to do all of the JOIN's in memory in the application. You can't make foreign key references across database unfortunately.
If you point the connection string for the ASP.NET Identity to the same database that your Subscription table is located in and run the application and create some users it should create those tables automatically.
I'm using the MVC4 Internet Application Code First. I was wondering if there is a way for me to retrieve the PasswordVerificationToken from the webpages_Membership table. I've tried following instructions in this older question.
I'm able to retrieve the PasswordVerificationToken from the webpages_Membership table however when I try to add a user to a role using Roles.AddUserToRole I get a foreign key constraint error.
Doesn't matter just added the simple membership tables to an entity model
I am working on my first ASP.Net MVC 4 app. I selected the Internet Application option and started with a LocaDB instance that had 4 tables in it (webpages_*).
I'm adding logging and error handling and I want to add ASP.Net Health Monitoring. To do that I had to run aspnet_regsql and now I have all of the aspnet_* tables along with the webpages_*.
What tables do I actually need for the Health Monitoring? Do I need all of them? Can I get rid of aspnet_Membership, for example.
I had tables for both Membership Provider and SimpleMembership Provider. Choosing one provider over the other allowed me to delete the cooresponding tables.
I'm using Symfony2 to authenticate users.
And I have two databases to store user information, db1 and db2.
The user table is stored in both databases, like username, password
How can I authenticate a user using both databases?
You could create a custom user provider (and inject in it your 2 entity managers), you check the first database, if your user isn't in it you check the second one.