locked
How the portalcontext getting the current user contact record in Customer portal? RRS feed

  • Question

  • Normally We get portal context like below

    var portal = PortalCrmConfigurationManager.CreatePortalContext();

    But i wanted to know how the portalcontext  finding the  contact which is authenticated for the current User in Customer portal. 

     
    //Getting the current user contact:
    var contact = portal.User;
     
    Can anyone have an idea? Thanks in advance
    

    senthilkumar.m
    Friday, October 7, 2011 6:13 PM

Answers

  • The CreatePortalContext() call will create a portal data context based on many different settings in your web.config.  This includes the CRM connection string and proxy account used to connect to the CRM instance.

    The portal.User attribute is probably the best place to get the current logged on web user.  The implementation underneath the hood will be reading this from the HttpContect.User.Identity.Name and then locating the appropriate contact record appropriate for that user.


    Shan McArthur www.shanmcarthur.net Check out the commercial edition of xRM portals @ www.adxstudio.com
    • Proposed as answer by Maria Joaquin Thursday, October 20, 2011 10:34 PM
    • Marked as answer by Palak Kadakia Thursday, November 10, 2011 10:32 PM
    Monday, October 17, 2011 10:50 PM
    Moderator

All replies

  • The CreatePortalContext() call will create a portal data context based on many different settings in your web.config.  This includes the CRM connection string and proxy account used to connect to the CRM instance.

    The portal.User attribute is probably the best place to get the current logged on web user.  The implementation underneath the hood will be reading this from the HttpContect.User.Identity.Name and then locating the appropriate contact record appropriate for that user.


    Shan McArthur www.shanmcarthur.net Check out the commercial edition of xRM portals @ www.adxstudio.com
    • Proposed as answer by Maria Joaquin Thursday, October 20, 2011 10:34 PM
    • Marked as answer by Palak Kadakia Thursday, November 10, 2011 10:32 PM
    Monday, October 17, 2011 10:50 PM
    Moderator
  • Thanks Shan...


    senthilkumar.m
    Friday, October 21, 2011 6:32 AM