10-01-06 06:26 AM
JC,
From first glance it appears that the UserObject.CurrentUser isn't being
updated as I'm sure you've identified. I don't have a copy of MSIB
installed at the moment as I'm knee deep in CS2007 work, but if you used
Reflector to look under the covers I would bet that CurrentUser is cached
until a new web request occurs.
The reason I say this is that I had to force CommerceContext to update for
similar purposes in our CS2002 release. I wanted to log the user in and
then update a few variables without waiting for the next web request.
Pseudo-code wise it looked something similar to the following:
CommerceContext CSContext = CommerceContext.Current;
...
Profile profile = RetrieveUserProfile(...);
...
CSContext.AuthenticationInfo.SetProfileTicket(profile.Id, true);
...
CSContext.UserID = profile.Id; <-- This was the force update
CSContext.UserProfile = profile; <-- This was the force update
Hope that helps!
Colin
"JC" <JC@discussions.microsoft.com> wrote in message
news:1D55C68E-F89A-4DD2-A233-88915F29BFC8@microsoft.com...[vbcol=seagreen]
> Colin,
> Thank you for your response.
> This is MSIB web app, Commerce 2002 and Content Management Server 2002.
> Below is the sample of my code:
>
> while (drUsers.Read())
> {
> // Create UserObject profile.
> UserObject userProfile = UserObject.CreateUserProfile (LogonName);
>
> // Set profile properties and save profile.
> SetProfileProperties (userProfile, LogonName, Password, FirstNAme,
> LastName);
> userProfile.Save();
>
> // Automatically authenticate user and move the anonymous information to
> the
> // // registered profile!!
>
> MicrosoftInternetBusinessSite.DefaultAuthProvider.Login (LogonName,
> Password);
> SiteAuthPolicyValidator.MoveAnonymousInfoToAuthenticatedUser();
>
> while (drAddresses.Read())
> {
> Address userAddress;
> // Set profile properties and update profile.
>
> SetAddressProperties (par1, par2, par3 ………);
> userAddress.Update();
> UserObject.CurrentUser.PreferredAddress = userAddress;
> UserObject.CurrentUser.Save();
> }
>
> MicrosoftInternetBusinessSite.DefaultAuthProvider.Logout();
> CommerceContext.Current.AuthenticationInfo.SetProfileTicket("",true);
> CommerceContext.Current.AuthenticationInfo.SetAuthTicket("",true);
> Session.Abandon();
> }
>
>
> "Colin Bowern" wrote:
>
[ Post a follow-up to this message ]
|