locked
Getting Credentials of logged in user in plugin RRS feed

  • Question

  • How do you get the credentials of the logged in user while in a plugin? When I use System.Net.CredentialCache.DefaultCredentials I am getting the credentials of the Network Service account.

    I need to get the credentials of the person that is logged in so I can pass them to an external webservice. We are using an on premise installation of crm 2011 and using Windows Authentication connected with our active directory. I have impersonation turned on in the web.config file. Any suggestions?

    Monday, September 24, 2012 7:26 PM

Answers

  • Plugins only return the CRM ID of the user under whose context the plugin is being executed. You cannot retrieve a token or the direct userid/password of the logged in user.

    HTH

    Sam


    Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    • Proposed as answer by Sam - Inogic Tuesday, September 25, 2012 3:18 AM
    • Marked as answer by jcasper Tuesday, September 25, 2012 5:38 PM
    Tuesday, September 25, 2012 3:18 AM

All replies

  • You are looking for InitiatingUserId in IExecutionContext 

    It might also be effected by the user context you set when registering the plugin.

    Here is a good blog post to refer to.

    UserId & InitiatingUserId properties in Plugin of CRM


    Jason Lattimer

    Monday, September 24, 2012 9:03 PM
    Moderator
  • I am not looking for the Id of the person. I am looking for their credentials so I can pass them to a webservice that I call in the plugin.
    Monday, September 24, 2012 9:09 PM
  • Plugins only return the CRM ID of the user under whose context the plugin is being executed. You cannot retrieve a token or the direct userid/password of the logged in user.

    HTH

    Sam


    Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    • Proposed as answer by Sam - Inogic Tuesday, September 25, 2012 3:18 AM
    • Marked as answer by jcasper Tuesday, September 25, 2012 5:38 PM
    Tuesday, September 25, 2012 3:18 AM