Commerce Server General - extending UserObject with new fields

This is Interesting: Free IT Magazines  
Home > Archive > Commerce Server General > April 2004 > extending UserObject with new fields





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author extending UserObject with new fields
Jason

2004-04-21, 4:36 pm

I have extended the User Profile by adding several fields to the database,
and creating new data objects and new profile definitions in the Commerce
Server Manager. I have also created a custom user registration page that
uses those new fields. I am attempting to make use of the "UserObject"
class on my site to register users. This class is part of the
"Microsoft.Solutions.Framework" package. This class allows you to set
properties for all the default user profile values and than call a "save()"
method to write everything to the database. However, this class obviously
does not know about my new fields. Is there a way to extend the UserObject
so that I can continue using it in the same way with my new fields? An
example of where this class is used is in the MSIB Adventure Works sample
site. Thank you.


Telmo Brito

2004-04-23, 10:46 am

Hi Jason,

I had the same problem, added new fields to the userobject, etc... The save() method does know of these new fields because the Microsoft.Solutions.Framework was coded only for these default fields of the Adventure works site.

What I did was instead of calling SetProfileProperties(userprofile) I commented this line and added the following code below:

AuthenticationInfo authInfo = CommerceContext.Current.AuthenticationInfo;
ProfileContext profContext = CommerceContext.Current.ProfileSystem;
Profile userprof;

userprof = profContext.CreateProfile(this.LogonName, "UserObject");

userprof.Properties["GeneralInfo.logon_name"].Value = this.LogonName;
userprof.Properties["GeneralInfo.user_security_password"].Value = this.Password;
userprof.Properties["AccountInfo.org_id"].Value = sOrgID;
userprof.Properties["GeneralInfo.first_name"].Value = this.FirstName;
userprof.Properties["GeneralInfo.last_name"].Value = this.LastName;
userprof.Properties["GeneralInfo.email_address"].Value = this.EmailAddress;
userprof.Properties["AccountInfo.account_status"].Value = 1;
userprof.Properties["AccountInfo.date_registered"].Value = DateTime.Now;
userprof.Properties["GeneralInfo.u_Cargo"].Value = CargoTextBox.Text; /// New fields that where added to the userobject
userprof.Properties["GeneralInfo.u_Departament"].Value = DepartamentTextBox.Text; /// New fields that where added to the userobject
userprof.Properties["GeneralInfo.user_title"].Value = TitleTextBox.Text;
userprof.Properties["GeneralInfo.tel_number"].Value = this.PhoneNumber;
userprof.Properties["GeneralInfo.fax_number"].Value = this.FaxNumber;
userprof.Properties["GeneralInfo.user_id_changed_by"].Value = Request.ServerVariables[ "AUTH_USER" ];
userprof.Properties["GeneralInfo.user_type"].Value = 1;
userprof.Properties["BusinessDesk.partner_desk_role"].Value = 1;
userprof.Update();

And instead of using save() you use update()

Hope this helps.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com