Before, I was creating a stand-alone web service in my DNN solution (rather than extending the WebService class in DNN). I thought maybe that was the reason it was not working, so I tried extending the WebService class instead, but for the same results.
I was also NOT setting the PortalID property on the user because I didn't know how to get to the PortalID in my CreateUser method. Then I came across the DNN core CreateUser method provided with the standard web services that come with the IWeb module install. This method was using the IWebCredentials property to get the portal ID to assign it to the new user (which is the only difference in my code and the core DNN code). Now, the problem is that it is complaining about IWebUserCredentials property being unreferenced. In other words, the IWebUserCredentials is NOTHING.
Here's my new function ... can someone spot where I am doing something wrong?
Public Function MyCreateUserMethod(ByVal sUserName As String, ByVal sPWD As String, ByVal sEmail As String) As String
Dim oUser As New DotNetNuke.Entities.Users.UserInfo
Dim oStatus As DotNetNuke.Security.Membership.UserCreateStatus
Try
oUser.PortalID = IWebCredentials.PortalID
oUser.Membership.Username = sUserName
oUser.Username = sUserName
oUser.DisplayName = sUserName
oUser.Membership.Password = sPWD
oUser.Membership.Approved = True
oUser.Membership.Email = sEmail
oUser.Email = sEmail
oUser.Profile.FirstName = "User"
oUser.Profile.LastName = "Creation Test"
oStatus = DotNetNuke.Entities.Users.UserController.CreateUser(oUser)
DotNetNuke.Entities.Profile.ProfileController.UpdateUserProfile(oUser)
If oStatus = DotNetNuke.Security.Membership.UserCreateStatus.Success Then
Return oUser.Username
Else
Return String.format("Error: {0}", oStatus.ToString)
End If
Catch ex As Exception
Return String.format("Exception: {0}", ex.Message)
End Try
End Function