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

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesProgramatically creating new userProgramatically creating new user
Previous
 
Next
New Post
2/1/2011 11:17 AM
 
We are creating an hr type application and would like to simplify the process of creating a new user.

We have a page with a requisition to fill a new position. This page contains details about the person that needs to be hired.

On this page there is a link to add a new user.

On our new user page we select name, address and email.

Based on the information on the req page the new user will be atached to certain roles.

The new user page needs to do 4 things.

Create a user
update the users address on their profile
asign the user to specific roles based on the req data
asign the new user id to the requisition record to close out the req.

I originally tried to accomplidh this by calling the AddUser and Add UserRole stored procedures directly and this appeared to work however DNN would throw an error when I attempted to log in and I was unable to figure out what else I might have been missing.

I have found examples on doing this through the DNN dlls but so far have been unable to get them to work.

The code I have tried is as follows:

Dim objmembership As New DotNetNuke.Entities.Users.UserMembership
Dim oUserInfo As New DotNetNuke.Entities.Users.UserInfo
Dim oprofile As New DotNetNuke.Entities.Users.UserProfile

oUserInfo.PortalID = 0
oUserInfo.IsSuperUser = False
oUserInfo.Username = FN.Value & LN.Value
oUserInfo.FirstName = FN.Value
oUserInfo.LastName = LN.Value
oUserInfo.DisplayName = FN.Value & " " & LN.Value
oUserInfo.Email = "siphco32@gmail.com"

objmembership.Approved = True
objmembership.Password = FN.Value & LN.Value & "1"
oUserInfo.Membership = objmembership

oprofile.City = City.Value
oprofile.Street = Address1.Value
oprofile.PostalCode = Zip.Value
oprofile.Region = St.Value
oUserInfo.Profile = oprofile

Dim objUserCreateStatus As UserCreateStatus = DotNetNuke.Entities.Users.UserController.CreateUser(oUserInfo)


I hard coded the portal ID to 0 as we only have one portal and that is what all of the other records indicate.

When I attempt to execute this it gives me a "NullReferenceException was unhandled by user code"

I have not downloaded the source code, I have only added a reference to the DotNetNuke and dotnetnule.membership.dataprovider dlls to my project.

I am developing this in Visual web developert 2010 express.

Any advice would be greatly appreciated.

Thanks



 
New Post
2/10/2011 10:49 AM
 
I am having the same problem
 
New Post
2/10/2011 3:45 PM
 
Eli, Are you doing this from within a custom DNN module or is it a separate website? If you are doing it outside of DNN (just adding the dll's to a project) then it is not as easy as you might imagine. I eneded up just using the asp.net membership provider and also wrapped up the DNN stored procs and called them directly.
 
New Post
2/17/2011 12:36 AM
 
Hi

Please check below link:
http://www.mindfiresolutions.com/How-...


Thanks
Sibabrata
www.mindfiresolutions.com 
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesProgramatically creating new userProgramatically creating new user


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