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.0UserController.CreateUser() and ProfileController.UpdateUserProfile.. UserController.CreateUser() and ProfileController.UpdateUserProfile..
Previous
 
Next
New Post
3/24/2008 3:13 PM
 

Hi. 

I will try to be concise and thorough.  My code creates a portal for a user that fills out my form.  All fields on the form correspond with Profile Properties enumerated in the portal template used to create the portal.   I'm having trouble adding a user, objUser, to the parent portal along with the information on the form.

Observe:

'create the portal
intPortalId = objPortalController.CreatePortal(...etc..etc)

'get the userInfo for the user we just specified in CreatePortal()
Dim objUser As UserInfo = UserController.GetUserByName(intPortalId, txtUsername.Text, True)

objUser.Profile.SetProfileProperty("CompanyName", txtCompanyName.Text)
'...etc etc. for several fields on the form.

'update their profile - this produces results that I expected.
ProfileController.UpdateUserProfile(objUser)

'add objUser to this portal - the 'parent'  - this does not produce results that I expect. (keep reading)
objUser.PortalID = PortalID
UserController.CreateUser(objUser)

'my desperate attempt to make their profile work
ProfileController.UpdateUserProfile(objUser)

After executing this code, objUser is an Administrator on their portal and their profile concurs with the data entered on the form.   objUser is also registered on the parent portal, but their profile properties do not concur with the data on the form.  Also, objUser is not an administrator.   This behavior is what I wanted, but I'm confused, because "Administrators" is listed as a role in objUser.Roles when adding to the parent portal.

Do the parent portal's Profile Properties need to match what I'm trying to add?   For instance, if "CompanyName" isn't defined as a Profile Property and I'm trying to apply changes to that field, will my attempts to modify that property be ignored?  

How can I add user to the parent portal, ensure their profile is accurate and they are NOT an administrator.

Thank you for your time.

Daniel

 

 
New Post
3/24/2008 6:51 PM
 

I'm really unsure about what to do here.     I've tried this as well.  No luck.

I thought this might help because a ProfileProperty does have a PortalID.

For Each def As ProfilePropertyDefinition In objUser.Profile.ProfileProperties
    objUser.Profile.ProfileProperties.Item(def.PropertyName).PortalId = PortalId

UserController.CreateUser(objUser)
ProfileController.UpdateUserProfile(objUser)

What can I do?   How do I add the user to more than one portal and retain their profile information?

 
New Post
3/24/2008 11:26 PM
 

try this:

intPortalId = objPortalController.CreatePortal(...etc..etc)

Dim userCreateStatus As UserCreateStatus = userCreateStatus.AddUser

Dim objNewUser As New UserInfo
objNewUser.PortalID = intPortalId
objNewUser.Email = txtEmail.Text
...
objNewUser.Membership.Password = txtPassword.Text
objNewUser.Membership.Approved = True
   
userCreateStatus = UserController.CreateUser(objNewUser)
   
Dim objUserInfo As UserInfo = UserController.GetUserByName(intPortalId, objNewUser.Username, False)
objUserInfo.Profile.SetProfileProperty("Title", txtTitle.Text)
UserController.UpdateUser(intPortalId, objUserInfo)


 
New Post
3/27/2008 9:25 AM
 

I was able to get this working.   The code I came up with looks pretty much like yours.  I went 1 step further and said ProfileController.UpdateProfile..  (or somthing like that). 

FYI:  The custom property you're setting MUST exist in the portal specified in the userInfo, or it will be discarded.  Someone chime in if i'm incorrect.

 

Nice moniker, by the way.

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0UserController.CreateUser() and ProfileController.UpdateUserProfile.. UserController.CreateUser() and ProfileController.UpdateUserProfile..


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