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

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationCustom Profile Properties in multiple Portals for a single user?Custom Profile Properties in multiple Portals for a single user?
Previous
 
Next
New Post
11/9/2009 3:48 PM
 

I have 2 Portals in my dnn installation... each Portal has a set of custom ProfileProperties defined, each with a unique Category name. ("PPA" and "PPB" - the actual ProfileProperties within each category have the same names: pp1, pp2, etc...)

My login script is all customized, and I have no problem creating and populating these ProfileProperties for a new user the first time they login to one of the 2 portals.  If, however, a user from Portal A attempts to login to Portal B, I cannot get the custom ProfileProperties to be created for Portal B.

At first, the values for the PPA properties were being updated when logging into Portal B... I've solved that issue, but now I cannot get the PPB properties to be created at all... What am I doing wrong here?

 

 

                //Get all of the Company specific Profile Properties

                ProfilePropertyDefinitionCollection ppdc = UserInfo.Profile.ProfileProperties.GetByCategory(strProfileCategory);

                ProfilePropertyDefinitionCollection myProps = ProfileController.GetPropertyDefinitionsByCategory(PortalId, strProfileCategory);

                sb.Append("<tr><td>Property Count: " + ppdc.Count.ToString() + " | " + myProps.Count.ToString() + "</td></tr>");

                ProfileController.UpdateUserProfile(objUserInfo, myProps);

 

                if (ppdc.Count != myProps.Count)

                {

                    sb.Append("<tr><td>Creating Profile Properties for " + strProfileCategory + "...</td></tr>");

                    UserInfo.Profile.ProfileProperties.AddRange(myProps);

                    

                    ppdc = UserInfo.Profile.ProfileProperties.GetByCategory(strProfileCategory);

                    sb.Append("<tr><td>Profile Properties Created! - " + ppdc.Count.ToString() + "</td></tr>");

                }

 

                sb.Append("<tr><td><ul>");

                for (int i = 0; i < ppdc.Count; i++)

                {

                    string strName = ppdc[i].PropertyName;

                    int intID = ppdc[i].PropertyDefinitionId;

                    ProfilePropertyDefinition ppd2 = objUserInfo.Profile.ProfileProperties.GetById(intID);//.GetByName(strName);

 

                    if (ppd2 == null)

                    {

                        ProfilePropertyDefinition userPPD = ProfileController.GetPropertyDefinition(intID);

                        UserInfo.Profile.ProfileProperties.Add(userPPD);

                        ProfileController.UpdateUserProfile(objUserInfo, objUserInfo.Profile.ProfileProperties);

                        ppd2 = objUserInfo.Profile.ProfileProperties.GetById(intID);

                    }

 

                    if (ppd2 != null)

                    {

                        sb.Append("<li>" + strName + ": " + ppd2.PropertyValue + " | " + ppd2.PropertyDefinitionId.ToString());

                        switch (strName)

                        {

                            case "pp1":

                                ppd2.PropertyValue = myValue;

                                break;

                            default:

                                ppd2.PropertyValue = ppd2.DefaultValue;

                                break;

                        }

                        sb.Append("<ul><li>New Value: " + ppd2.PropertyValue + "</li></ul>");

                        UserInfo.Profile.SetProfileProperty(strName, ppd2.PropertyValue);

                        ProfileController.UpdateUserProfile(objUserInfo, objUserInfo.Profile.ProfileProperties);

                        sb.Append("</li>");

                    }

                    else

                    {

                        sb.Append("<li>Property ID Not Found: " + strName + " | " + intID.ToString() + "</li>"); (This error line is returned)

                    }

                }

 

My logging returns the following:

Updating Profile for Portal B...
Property Count: 0 | 6
Creating Profile Properties for Portal B...
Profile Properties Created! - 6
  • Property ID Not Found: pp1 | 84
  • Property ID Not Found: pp2 | 85
  • Property ID Not Found: pp3 | 86
  • Property ID Not Found: pp4 | 87
  • Property ID Not Found: pp5 | 91
  • Property ID Not Found: pp6 | 88

 

The UserProfile table has links to the Profile and ProfilePropertyDefinition for PortalA, but it does not contain the required links for PortalB...

It seems to me that the code is correctly looking for the ProfileProperties for the correct Portal and Category name, it is finding that these properties do not exist, it attempts to create them (and thinks that it does), and then attempts to set the values for the ProfileProperties, but ppd2 is returning null since the ProfileProperties were never created in the previous step.  So I believe the red lines above are my issue, but I don't understand why that would seem to work for completely new users in either Portal but not work for existing Users when attempting to login to the Portal in which they were not initially created.

I feel like there is some redundant code up there, but I've just been trying to add commands to force the creation of these Properties... I'm sure there is some stuff I need to remove.  Any help, as always, is appreciated; thanks!

 

 
New Post
11/11/2009 4:24 PM
 

 In case this ever helps anyone else, I finally got this working... just had to find the right methods to call... *thinks about how nice real documentation would be*

 

                //Get the Company specific Profile Properties for the User

                ProfilePropertyDefinitionCollection ppdc = UserInfo.Profile.ProfileProperties.GetByCategory(strProfileCategory);

                //Also get a list of all available Company specific Profile Properties

                ProfilePropertyDefinitionCollection myProps = ProfileController.GetPropertyDefinitionsByCategory(PortalId, strProfileCategory);

                

                //If the number of Company specific Profile Properties assigned to the User does not match the total

                //number of Company specific Profile Properites, we need to create them.

                sb.Append("<tr><td>Property Count: " + ppdc.Count.ToString() + " | " + myProps.Count.ToString() + "</td></tr>");

                if (ppdc.Count != myProps.Count)

                {

                    objUserInfo.Profile.InitialiseProfile(PortalId, true);

                    sb.Append("<tr><td>Creating Profile Properties for " + strProfileCategory + "...</td></tr>");

                    UserInfo.Profile.ProfileProperties.AddRange(myProps);

                    ppdc = UserInfo.Profile.ProfileProperties.GetByCategory(strProfileCategory);

                    sb.Append("<tr><td>Profile Properties Created! - " + ppdc.Count.ToString() + "</td></tr>");

                }

                ProfileController.UpdateUserProfile(objUserInfo, ppdc); 

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationCustom Profile Properties in multiple Portals for a single user?Custom Profile Properties in multiple Portals for a single user?


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