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...UserController.CreateUser causes InvalidUsername statusUserController.CreateUser causes InvalidUsername status
Previous
 
Next
New Post
5/8/2007 11:40 AM
 

I am basically writing a dual login so that I can easily integrate my company's application with DotNetNuke.  I have everything figured out and have done this before in the older versions but can't get it to work in 4.5.1  My code is as follows:

'Begin to build DNN if first time logging in

objNewUser.Profile.Unit = htDNNUserInfo(

"ALine2")
objNewUser.Profile.Street = htDNNUserInfo(
"ALine1")
objNewUser.Profile.City = htDNNUserInfo(
"City")
objNewUser.Profile.Region = htDNNUserInfo(
"State")
objNewUser.Profile.PostalCode = htDNNUserInfo(
"Zip")
objNewUser.Profile.Country = htDNNUserInfo(
"Country")
objNewUser.Profile.Telephone = htDNNUserInfo(
"Phone")
objNewUser.Membership.Email = htDNNUserInfo("Email")
objNewUser.Membership.Username = txtUsername.Text
objNewUser.Profile.Fax = htDNNUserInfo("Fax")
objNewUser.Profile.IM =
"N/A"
objNewUser.Profile.Website = "N/A"
objNewUser.Profile.PreferredLocale = "en-US"
objNewUser.Profile.TimeZone = Convert.ToInt32(-300) 'Defaults to Eastern Time Zone

objNewUserStatus = UserController.CreateUser(objNewUser)

END OF CODE

This is a simple new user created progromattically.  The username i'm trying to register is "kcabrams".   UserController.CreateUser(objNewUser) returns InvalidUserName and my DNN user does not get added.  Please help.  I used to do this with AddUser with no problems what so ever.

KC

 
New Post
5/8/2007 1:32 PM
 

WooT!! Figured it out:

Please note that in a rush to put my code up I forgot to a couple mandatory fields above.  ie: objNewUser.Profile.Firstname, lastname, etc

Apparently you need to set a couple of other values before the CreateUser function can be used.  They are as follows:

objNewUser.Profile.InitialiseProfile(PortalId)
objNewUser.Email = htDNNUserInfo("Email")
objNewUser.FirstName = htDNNUserInfo("FName")
objNewUser.LastName = htDNNUserInfo("LName")
objNewUser.Username = txtUsername.text
objNewUser.DisplayName = objNewUser.FirstName & " " & objNewUser.LastName

That is why I was getting a InvalidUsername error before because objNewUser.Username was blank! (eventho I was populating objNewUser.Membership.Username field which was fine with the old AddUser function)

 objNewUser.Profile.InitialiseProfile(PortalId) is used to set up a blank profile and should be used before you start setting your values.

Enjoy!

 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...UserController.CreateUser causes InvalidUsername statusUserController.CreateUser causes InvalidUsername status


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