Bulk Insert for Users

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
June
Ensign (ENS)
Ensign (ENS)
Posts: 11
Joined: Wed Oct 24, 2012 11:24 am

Bulk Insert for Users

Post by June » Thu Aug 28, 2014 1:26 pm

Is it possible to do an sql insert into the Users tables (and also User Passwords and User Groups) for a bulk insert?

The reason I am asking is that we are launching a site for employees only. There are over 300 employees to add.
  • We want to pre-add the employees and lock out un-registered users (and not allow users to register)
  • We'd rather not add each employee individually.
Also, is there a way to get around using the email as the user name?

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Bulk Insert for Users

Post by jmestep » Fri Aug 29, 2014 4:05 am

You can do a bulk insert, but the passwords would not be encrypted/encrypted correctly. You might be able to work around that if the users get a forgot password email the first time they log in. They can then change the password.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Bulk Insert for Users

Post by mazhar » Fri Aug 29, 2014 4:06 am

Is it possible to do an sql insert into the Users tables (and also User Passwords and User Groups) for a bulk insert?
You should be able to do that though I think you will have to reset passwords afterwards one by one from admin panel. Alternatively if you know the programming you can write small piece of code to create user using AbleCommerce API. This way you can provide a password during setup with option to change it upon first login.
We want to pre-add the employees and lock out un-registered users (and not allow users to register)
Our system have this ability. All you will be need to set store access setting in admin panel.
Also, is there a way to get around using the email as the user name?
Yes, its possible. We impose this requirement of having Email as user name at front end only. You can create users with username other then Email address.

June
Ensign (ENS)
Ensign (ENS)
Posts: 11
Joined: Wed Oct 24, 2012 11:24 am

Re: Bulk Insert for Users

Post by June » Wed Sep 17, 2014 6:12 am

Thank you very much for your replies. You all are very helpful!

Here is the SQL in case someone else may want to do this in the future. These are the tables that are affected. I was able to encrypt a first time password by using the SHA1 encryption tool (Visual Studio).
Please note that there are values you have to replace in the code - values to replace are between the <> AND you need to make sure you want the static values I am passing so - USE CAUTION and analyze. Do not just copy and paste.

-- Add a user to the ac_Users table
INSERT INTO dbo.ac_Users
([StoreId],[UserName],[LoweredUserName],[Email],[LoweredEmail],[PrimaryWishlistId],[IsApproved],[IsAnonymous],[IsLockedOut],[CreateDate],[FailedPasswordAttemptCount],[FailedPasswordAnswerAttemptCount],[TaxExemptionType])
VALUES
(1,'<username>','<username.ToLower>','<email>','<email.ToLower>',0,1,0,0,'2014-08-29 00:10:27.023',0,0,0)

-- Set the user’s group
INSERT INTO [dbo].[ac_UserGroups]
([UserId], [GroupId])
VALUES
(<userid from dbo.ac_Users record insert>,8)

-- Set the user's password to Coleman2*14
INSERT INTO dbo.ac_UserPasswords
([UserId],[PasswordNumber],[Password],[PasswordFormat],[CreateDate],[ForceExpiration])
VALUES
(<userid from dbo.ac_Users record insert>,1,'Jt2MLOhY2oE4jGZou3kvbI3Rgu2xhkCedQ==','SHA1','2014-08-29 00:10:27.023',1)

-- Set the user’s first and last name- WATCH FOR APOSTROPHES IN NAMES!!
INSERT INTO [dbo].[ac_Addresses]
([UserId],[FirstName],[LastName],[Residence],[Validated],[IsBilling])
VALUES
(<userid from dbo.ac_Users record insert>,'<first name>','<last name>',1,0,1)

Post Reply