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!