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