2

Can someone please tell me if it possible to create a new user in a dotnetnuke application from code? I have a list of users that I wish to be added via a windows service.

I've figured out how to write the t-sql side of things but I need to pass in the encrypted password into the procedure, I think I know how to do this as I have access to the machine key, but in the database there is an extra field called passwordsalt, how do I generate this?

rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
Martin
  • 587
  • 1
  • 6
  • 18

2 Answers2

3

UserController class has static methods:

CreateUser(ByRef objUser As UserInfo) As UserCreateStatus

GeneratePassword() As String

ChangePassword(ByVal user As UserInfo, 
               ByVal oldPassword As String, 
               ByVal newPassword As String) As Boolean

Before calling CreateUser, you'll need to create a UserInfo object and set the properties required for a user, such as the Username. UserController passes the UserInfo to the membership provider, which validates and creates the user. See UserController and AspNetMembershipProvider in the DNN source for more details.

mika
  • 6,812
  • 4
  • 35
  • 38
  • ok so I'm now trying to use DNN usercontroller class but I keep getting the following error "The type initializer for 'DotNetNuke.Entities.Profile.ProfileController' threw an exception" – Martin Sep 26 '11 at 13:52
  • Update your original question with what exception you are getting. I am going to guess your code is simply wrong. I am going to guess your UserInfo object is null. – Security Hound Sep 27 '11 at 11:15
2

Can someone please tell me if it possible to create a new user in a dotnetnuke application from code?

If it wasn't possible then dotnetnuke itself couldn't create a user. Look at the code for DotNetNuke and see how a user is created.

I've figured out how to write the t-sql side of things but I need to pass in the encrypted password into the procedure, I think I know how to do this as I have access to the machine key, but in the database there is an extra field called passwordsalt, how do I generate this?

Do yourself a favor and do NOT run your own t-sql query use the method that creates a user instead.

Security Hound
  • 2,577
  • 3
  • 25
  • 42