Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to implement functionality with impersonation?

Posted on by

Hello All Experts,

Can anyone help me in achieving the below functionality.

1. Creation of the Customer Portal such that customer can log in and 

      i. Create a case and send to mscrm.

      ii. Get the current status of the case.

2. This user will not be having the permission on the crm application

    so want to use some another person in crm who will work on behalf of this person.

can anyone help me in implementing this type of functionality.

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to implement functionality with impersonation?

    My understanding is that your Customers are Contacts in CRM , and users in the web App

    - Who can do what :should be controlled in the web App : so if the customer in the web App is asigned a web Role in your that allows him to create a case , then he can and you will invoke the web Service .  (here you can send the CRM id of the CRM contact)

    the web service will invoke the crm operation using the credential of any CRM user you want : it could be a user with Admin security role or a user with Custom security role to act only on specific entities.

    In CRM you can add a custom lookup field to the Conact (Created by) entity so it will map to the customer which the web service executed the message on behalf

    This lookup can be used for filtering in reports later on .

  • EmployeeOcta Profile Picture
    EmployeeOcta on at
    RE: How to implement functionality with impersonation?

    Hello Clab01,

    thanks for your suggestion, this is exactly i want to do, but which user from the crm needs to be taken into consideration which will work on behalf of this customer.

    second next time if we want to generate a report how we will come to know that the case is of this particular customer and more later scenarios.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to implement functionality with impersonation?

    Hello , I would suggest you develop a Middle layer : a WCF service or a ASP .net web APi which exposes the methods you want your webapp to do :

    - Get Case

    - Create Case.

    the WCF will execute your queries using CRM user credentials .

    Your web app will invoke the web service (wcf ) without credentials .

    Marks As Answer If it helps you.

  • EmployeeOcta Profile Picture
    EmployeeOcta on at
    RE: How to implement functionality with impersonation?

    Hello Emre,

    I want to use custom developed website.

  • Suggested answer
    Emre GULCAN Profile Picture
    Emre GULCAN 2,379 on at
    RE: How to implement functionality with impersonation?

    Hi,

    Do you want use "Dynamics Portal" or custom developed website for this?

    Actually I'm new-bee about Dynamics Portals but there are more options about this (you should do your settings with Entity Permissions / Scopes, Views etc), this document helps you 

    If you create a custom web application, just create a Query (fetch or QueryExpression) and send your customer ID to your service to retrieve data.

  • EmployeeOcta Profile Picture
    EmployeeOcta on at
    RE: How to implement functionality with impersonation?

    Hello Emre,

    i want to allow the individual crm contact to access the cases which belongs to  them .

    those cases will be displayed in the custom web application where the contact will login first.

  • Emre GULCAN Profile Picture
    Emre GULCAN 2,379 on at
    RE: How to implement functionality with impersonation?

    Hi,

    You can only impersonate with "Systemuser", you cannot use other entities (like contact). For your question, you can create a case record and set "customer" field with your contact record.

  • EmployeeOcta Profile Picture
    EmployeeOcta on at
    RE: How to implement functionality with impersonation?

    One Question here.

    The person who is accessing the external website will be the contact in the crm.

    Now if he is the only contact then how can we impersonate , unless he has got the accessibility to the crm.

    a simple contact do not have AD account.

    can anyone help me in finding the correct solution for such requirement?

  • Suggested answer
    Emre GULCAN Profile Picture
    Emre GULCAN 2,379 on at
    RE: How to implement functionality with impersonation?

    Hi,

    You can use basically "Microsoft.Xrm.Client" dll (download from NuGet) and modify your "app/web.config" file like this, this informations should be for administrator (I'm using like this way)

     <connectionStrings>
        <add name="myconnection" connectionString="Url=ORGANIZATIONSVC URL; Username=DOMAIN\USERNAME; Password=PASSWORD" />
      </connectionStrings>


    If you use code below, you can connect to your CRM organization with your credentials (from app/web.config)

    var connection = new CrmConnection("myconnection");
    IOrganizationService _organizationService = new OrganizationService(connection);


    If you use code below, you can impersonate with your user without credential (username / password), just use Systemuser ID 

    var connection = new CrmConnection("myconnection");
    connection.CallerId = Guid.Parse("IMPERSONATED SYSTEMUSER ID");
    IOrganizationService _organizationService = new OrganizationService(connection);


  • EmployeeOcta Profile Picture
    EmployeeOcta on at
    RE: How to implement functionality with impersonation?

    Hello Mostafa,

    can you give a sample example for this.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans