I am trying to import 1000 users to aspnet_membership table using TSQL. Could anyone please point me to the right direction whether this is possible at all?
The requirement is to:
- Create Users and Profiles.
- Generate password.
- Email password to end users.
Thank you.
If you are going to use unencrypted password format then you can just call dbo.aspnet_Membership_CreateUser stored procedure from your SQL to create users. It takes a bunch of params;
@ApplicationName
@UserName
@Password
@PasswordSalt
@Email
@PasswordQuestion
@PasswordAnswer
@IsApproved
@CurrentTimeUtc
@CreateDate
@UniqueEmail
@PasswordFormat
@UserId (output)
You can generate password in TSQL and you can send emails from TSQL. This stored procedure: dbo.aspnet_Profile_SetProperties would set Profile properties.
If you need hashed or encrypted passwords .. then probably you have to write some admin code that uses Membership and Profile providers. It should be fairly easy to do so. Providers have all the methods that are needed to generate and encrypt passwords.
To create users you would just call:
CreateUser
( string username,
string password,
string email,
string passwordQuestion,
string passwordAnswer,
bool isApproved,
object providerUserKey,
out MembershipCreateStatus status )
method and pass the data in. The encryption will happen inside the method.
So TSQL could work if you do not need to encrypt or hash passwords. Otherwise it wouldbe some coding .. but really minimal.