How to create user directly in database

42 Rio asked on February 21, 2019 11:05

Hi, we need to create new users directly into database (instead of using API). What is the bare minimum of fields needet to be filled? I assume it means createrecords in CMS_User, CMS_UserRole, CMS_UserSettings and CMS_UserSite tables. Is there anything else to be done or is there any database procedure that can do that? Thank you.

Correct Answer

vasu yerramsetti answered on February 21, 2019 15:28


Your are correct. There is no stored procedure. User record get stored in the following sequence in database with sample INSERT Statement with mandatory fields.

  • CMS_User INSERT INTO CMS_User(UserName,Email,UserGUID,UserLastModified,UserPrivilegeLevel,UserPasswordFormat,UserCreated) Values('vasu','', NewID(),GETDATE(),3,'PBKDF2',GETDATE())
  • CMS_CMS_UserSettings [optional] INSERT INTO CMS_UserSettings (UserSettingsUserID,UserSettingsUserGUID) VALUES(@UserID, @UserGUID)

You can get the @UserID and @UserGUID from CMS_User table

  • CMS_UserSite [optional] INSERT INTO CMS_UserSite(UserID,SiteID) Values(@UserID,SiteID)
  • CMS_UserRole[optional] INSERT INTO CMS_UserRole(UserID,RoleID) VALUES(@UserID,@RoleID)

Create user with UserPrivilegeLevel 3, then no need to insert into remaining tables. User can login into the CMSDesk as administrator and user can set remaining properties.

Note: Kentico does not recommend working directly on Database tables.

0 votesVote for this answer Unmark Correct answer

Recent Answers

42 Rio answered on February 21, 2019 16:28

Thank you for your answer. I am aware that this approach is not the best, but we are forced to go that way because of our client demands.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.