Base solution for your next web application
Open Closed

How to transfer user info between database #5293


User avatar
0
fguo created

I need to transfer hundreds user info from another application to AbpUsers table to avoid manually enter them in admin interface. I am going to map the columns, such as:

insert into AbpUsers (AccessFailedCount, CreationTime, EmailAddress, UserName) select 0, getdate(), email, login from TableOnAnotherApp

Is it possible? What is the best practice in this scenario?

I am concerning the column "Password", which is "not null" and must be a token. Can I just make up it as a plan string?

For the ConcurrencyStamp and SecurityStamp columns, can I just leave it as null?

Thanks,


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    ConcurrencyStamp and SecurityStamp are GUID strings. sql is NEWID()

    1. You can write a special interface for importing users in bulk. According to the user data of TableOnAnotherApp, the user information (such as username, email, password, etc.) needed by the current application is constructed. Internal use of _userManager.CreateAsync. The framework will automatically handle other User attributes.

    2. If you want to use sql insert statement, please set a string password, bypass sql constraints, and then write a loop in the application to query the imported user, and then set a new password for them.

  • User Avatar
    0
    bbakermmc created

    We use SQL just fine. Just generate a new user with a default password you want to use, take the hash and use it. Set user to change password on login. Dont do any of this looping in C# crap, waste of time for a 1x import.

    There is a table in the host that you also need to write the newly created user account info to also.

    If you make a new user, just look in all the user tables in the tenant and host to trace what needs to be done.

    Our DBAs load our tenant dbs with users/permissions/roles for all the internal people that work on that tenants account and we have no issues. (Now we get to add WsFederation so another table to write to if you want to do that too :) )

  • User Avatar
    0
    alper created
    Support Team

    hi,

    You can use the same Password, ConcurrencyStamp and SecurityStamp for all users. The only downside is; all the users will have the same password.

    insert into AbpUsers (AccessFailedCount, CreationTime, EmailAddress, UserName)
    select 0, getdate(), email, login
    FROM [MyOtherDb].dbo.myOtherUserTable