Search code examples
dynamics-crm-2011dynamics-crmdynamics-crm-2013

Get the context of a team in dynamics crm


I have a list of temas in dynamics crm, I want when I create the context of crm will have only the context of one team, i.e the team will not have the access to records of other teams.

I have try to change the callerID of the organizationproxy like this:

        //original context
        OrganizationServiceContext contextORI = new OrganizationServiceContext(organisationProxy);
        //i search th team
        team team= (from k in contextORI.CreateQuery<Utilisateur>()
                            where k.Id == TEAM.Id
                            select k).FirstOrDefault();
        //i change the caller of organisationProxy
        this.organisationProxy.CallerId = team .Id;
        //i create the new context
        OrganizationServiceContext context = new OrganizationServiceContext(organisationProxy);

But the team have always the access to all results

Do you have any idea how can I have only the context of the team ?


Solution

  • This wont work.

    The OrganizationServiceProxy.CallerId expect the id of a systemuser. https://msdn.microsoft.com/en-us/library/microsoft.xrm.sdk.client.organizationserviceproxy.callerid.aspx

    You could impersonate a member of that team and provided the user and team only have User/Team read access against the entity you are querying the context should be appropriately filtered.