Please use the code below to create impersonated CRM service in CRM 2011.
public static IOrganizationService Service() { ClientCredentials Credentials = new ClientCredentials(); Credentials.Windows.ClientCredential.UserName ="Impersonate User ID"; Credentials.Windows.ClientCredential.Password ="Impersonate User ID password"; //Update the below URL as per your environment Uri OrganizationUri = new Uri("http://serverName/OrganizationName/XRMServices/2011/Organization.svc"); Uri HomeRealmUri = null; //Get the CRM Service from the CRM Service Proxy using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null)) { IOrganizationService service = (IOrganizationService)serviceProxy; return service; } }
No comments:
Post a Comment