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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Creating User ProgramaticallyCreating User Programatically
Previous
 
Next
New Post
9/1/2009 8:03 PM
 

 Hello everyone, I found a few threads discussing how to create users programatically here in the forum but I still have a question, follows below the code that I use to create a new user:

 

                                objHotsiteOwner = New UserInfo
                                objHotsiteOwner.Profile.InitialiseProfile(intPortalId)
                                objHotsiteOwner.Profile.TimeZone = Me.Container.PortalSettings.TimeZoneOffset
                                objHotsiteOwner.Profile.PreferredLocale = "en-US"
                                objHotsiteOwner.Profile.Country = "N/A"
                                objHotsiteOwner.AffiliateID = -1
                                objHotsiteOwner.FirstName = txtFirstName.Text
                                objHotsiteOwner.LastName = txtLastName.Text
                                objHotsiteOwner.Username = txtUsername.Text
                                objHotsiteOwner.DisplayName = txtFirstName.Text + " " + txtLastName.Text
                                objHotsiteOwner.Email = txtEmail.Text
                                objHotsiteOwner.IsSuperUser = False
                                objHotsiteOwner.Membership.Approved = True
                                objHotsiteOwner.Membership.Password = txtPassword.Text
                                objHotsiteOwner.Membership.PasswordQuestion = txtQuestion.Text
                                objHotsiteOwner.Membership.PasswordAnswer = txtAnswer.Text
                                objHotsiteOwner.Profile.FirstName = txtFirstName.Text
                                objHotsiteOwner.Profile.LastName = txtLastName.Text
                                objHotsiteOwner.PortalID = intPortalId

the user is created sucessfully and I can log with it on the portal which I registered it, but there's something weird going on and I would like to know if anyone else had such problem...

whenever I login with the user I created with the code above and try to upload a file using a custom control an exception is thrown saying that the file is invalid (I try to create a System.Drawing.Image from the InputStream of the postedfile) and then DNN simply logs me out of the application and I have to log back again... and the error persists with no apparent solution (the size of the file is ok apparently and the position of the stream is at 0 as needed)

BUT... if I create a user within the user administration available from dnn and try to do the same thing I can successfully upload the file with no exception thrown, the only difference here is that the current user logged is a user created by dnn and not by the code I posted above

do u guys have any idea of what could it be?

and if you are curious about the file upload control, it's quite simple:

 

                Dim postedFile As HttpPostedFile = Request.Files("Filedata")
                Dim img As System.Drawing.Image = System.Drawing.Image.FromStream(postedFile.InputStream) 'EXCEPTION HERE

everything seems to be the same thing, every setting, every variable on both users... the only real difference is that one user is created by the code I wrote above and the other user (the one that works) is created by dnn

thanks in advance!

 

 

 
New Post
9/1/2009 10:01 PM
 

i'm not sure, but maybe you can check the role for the user. because i did not see any code for adding a role to the user.

maybe you can compare the role between the users (the user programatically created and the user created using DNN).

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Creating User ProgramaticallyCreating 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