Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...vCreating new user programaticallyvCreating new user programatically
Previous
 
Next
New Post
8/26/2009 10:10 AM
 

Hi I am using this code snippet to create new user.  But it does not create anything, i get no errors. dont really know what i am doing wrong.

 

 

 

 

 



 




Dim userCreateStatus As New UserCreateStatus


Dim objNewUser As New DotNetNuke.Entities.Users.UserInfo
objNewUser.Profile.InitialiseProfile(Me.PortalSettings.PortalId)
objNewUser.PortalID = Me.PortalSettings.PortalId
objNewUser.PortalID = PortalId
objNewUser.Email = username & "@minasu.com"
objNewUser.Username = "al"
objNewUser.DisplayName = String.Concat(username, " ", Password)
objNewUser.Membership.Password = "osman"
objNewUser.Membership.Approved = True
objNewUser.Profile.PreferredLocale = Me.PortalSettings.DefaultLanguage
objNewUser.Profile.TimeZone = Me.PortalSettings.TimeZoneOffset
Response.Write(Me.PortalSettings.PortalId)

'userCreateStatus = UserController.CreateUser(objNewUser)
Dim objStatus As UserCreateStatus = DotNetNuke.Entities.Users.UserController.CreateUser(objNewUser)
'Response.Write(userCreateStatus.ToString())

' set-up the arguments for the status of the user creation
Dim args As DotNetNuke.Entities.Modules.UserUserControlBase.UserCreatedEventArgs
If objStatus = UserCreateStatus.Success Then
args = New _
DotNetNuke.Entities.Modules.UserUserControlBase.UserCreatedEventArgs(Me.User)
args.Notify = True
Else ' registration error
args = New _
DotNetNuke.Entities.Modules.UserUserControlBase.UserCreatedEventArgs(Nothing)
args.Notify = False
End If
args.CreateStatus = objStatus
 
New Post
8/26/2009 10:22 AM
 

Looks like your code was mangled a bit.

Here is a blog post that shows how to do it, this is a C# example, but conversion to VB is easy enough.


-Mitchel Sellers
Microsoft MVP, ASPInsider, DNN MVP
CEO/Director of Development - IowaComputerGurus Inc.
LinkedIn Profile

Visit mitchelsellers.com for my mostly DNN Blog and support forum.

Visit IowaComputerGurus.com for free DNN Modules, DNN Performance Tips, DNN Consulting Quotes, and DNN Technical Support Services
 
New Post
8/26/2009 10:52 AM
 

ok thanks

 

here is what i'm trying to do. correct me if i'm worng.

I am authenticating users through an API,  if they are a valid user, then i want to call your routine that creates the new user. then log then in DNN as that new user

So i want to place this code in the login in module right above where DNN authenticates users?

here is my code this not working i dont know what i'm doing wrong.

 

 

 



Dim oUser = New UserInfo()
oUser.PortalID = Me.PortalId
oUser.IsSuperUser = False
oUser.FirstName = "FirstName"
oUser.LastName = "LastName"
oUser.Email = "test@test.com"
oUser.Username = "MyUsername"
oUser.DisplayName = "FirstName LastName"


'Fill MINIMUM Profile Items (KEY PIECE)
oUser.Profile.PreferredLocale = PortalSettings.DefaultLanguage
oUser.Profile.TimeZone = PortalSettings.TimeZoneOffset
oUser.Profile.FirstName = oUser.FirstName
oUser.Profile.LastName = oUser.LastName

'//'Set Membership
Dim oNewMembership = New UserMembership()
oNewMembership.Approved = True
oNewMembership.CreatedDate = System.DateTime.Now
oNewMembership.Email = oUser.Email
oNewMembership.IsOnLine = False
oNewMembership.Username = oUser.Username
oNewMembership.Password = "test"

'//Bind membership to user
oUser.Membership = oNewMembership
UserController.CreateUser(oUser)
Response.Write(UserController.CreateUser(oUser))
'//Add the user, ensure it was successful
'if UserCreateStatus.Success == UserControfller.CreateUser(ref oUser) then

If UserCreateStatus.Success = UserController.CreateUser(oUser) Then
Response.Write(UserController.CreateUser(oUser))
End If
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...vCreating new user programaticallyvCreating new user programatically


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out