Commerce Server Blog

Build world class ecommerce applications using Microsoft Commerce Server
  •  
  • Home
  • About
  • Advertise
  • Copyright Policy
  • Disclaimer

Automatic User Creation / login in Commerce Server Starter Site

ravikanth | August 17, 2008

In Microsoft commerce server forums, I came across one post with a nice requirement. The requirement was

  1. Create a user in Starter site without manual entry . ie User Details would come from Active Directory, using this details , starter site should create a user profile if he visits the site for first time. 
  2. If an Existing user visits the Starter site, his user profile details should be fetched automatically without entering username and password.

Here is the resolution for this requirement.

Pre-requisites

  • Instead of having the same profile data at two different locations (commerce server & AD), if possible, try to extend the commerce server to map the fields in AD (optional).
  • By default commerce server uses email ID as primary key in User Profile. You can extend profile system to make user Id (which holds AD user ID) as primary key. To change primary key value, check below site for more details.
    http://techblog.ravikanth.net/blog/cns!F348D7145D1BE6C2!459.entry
  • Enable windows authentication on starter site.

Authentication Process: 

  • Get logged in user ID in to the application. We will check whether profile session available.
  • If there is no profile session available, we will get user details using WindowsIdentity class.
  • Call commerce server profile system to get user profile details
  • If nothing is returned, we will create a user profile for that user. We will fetch necessary information from active directory and create an entry in commerce server profile system.
    Note: The password will be same for all users – say Pass@123.
  • Store user profile details in session for further use.

I tested this approach on starter site and it worked. For instance, for auto-login feature I had added below code in standardLayoutMaster.CS init() method.

bool isAnonymousUser = SiteContext.Current.IsAnonymousUser;
if (isAnonymousUser == true)
{
     CurrentUser.RefreshCache();
     WindowsIdentity identity = WindowsIdentity.GetCurrent();
     string[] userName = identity.Name.ToString().Split(”);
     // Set new user id.
     Guid registeredUserId = (Guid)Membership.GetUser(userName[1]).ProviderUserKey;
     CommerceContext.Current.UserID = registeredUserId.ToString(”B”);
     SiteSecurity.CreateUserCookie();
     LogCommerceEvent.UserSignIn(registeredUserId);
}

Every time, application checks whether the current user is anonymous user. If yes, it will get user name (remove domain/system name) from windows identity and pass it to commerce server to get user Id (guid). This GUID is assigned to commerce server context.

Comments
No Comments »
Categories
commerce server 2007
Tags
auto login process, automatic user creation, commerce server, starter site customization
Comments rss Comments rss
Trackback Trackback

Sign up for Newsletter


Categories

Quiz

  • Catalog Quiz for Beginners
  • Profile Quiz for Beginners
  • Quiz 1 for Advance Users
  • Quiz for Beginners

Recent Posts

  • Configuration Error: Could not load type ‘Microsoft.Commerce.Providers.SharePointCommerceOrderModule from assembly because the parent type is sealed
  • How commerce server Site Terms are stored
  • Troubleshoot: An unexpected error has occurred.
  • Design consideration for developing commerce server catalog system
  • Troubleshoot: AuthManager(CommerceServer): Error reading Commerce Server administration database
  • Account Creation Approval Process
  • Troubleshoot: Unauthorized exception when the new user tries to access MyAccount page
  • Microsoft Commerce Server 2009 code name "R2" – January 2010 Community Technical Preview
  • Merchant Access to Catalog Manager
  • Commerce Server 2009 December VPC ready for download

Archives

  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008

Tags

add discounts add images to profile Advantages of commerce server approve discounts authentication auto login process automatic user creation basket Brand Management business tools campaign management Catalog catalog import Category CategoryConfiguration cc_number checkout commerce 7 commerce server commerce server 2002 commerce server 2007 commerce server 2007 Display Types Commerce Server SP2 discounts ecommerce Estimation inventory Kanth Koppala marketing system migration error Mojave Product profile profile subsystem property metadata purchase order quick checkout Ravi Ravi Kanth site cache refresh starter site tools transactions error Variant
(c) 2009 Commerce Server Blog. All rights Reserved. Articles cannot be reproduced without permission from the author.Write to me at kanth@ravikanth.net if you have any comments, questions, suggestions about this site or would like to send us a tip
About Us | Terms of Use | Disclaimer | Advertise .