Thursday, November 27, 2014

Creating OrganizationService in MS CRM

Mostly creation of an organization service can be done in two ways.

1. Using user credentails
2. Using Network credentials.

1. Creating an organization service using credentials:

            OrganizationUri = new Uri(ConfigurationManager.AppSettings["OrgURL"].ToString());
            HomeRealmUri = null;
            Credentials = new ClientCredentials();
            Credentials.Windows.ClientCredential = new System.Net.NetworkCredential("username","password","domain");
            DeviceCredentials = new ClientCredentials();
            _serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, DeviceCredentials);
            _service = (IOrganizationService)_serviceProxy;

2. Creating organization service with Network credentials.

            OrganizationUri = new Uri(ConfigurationManager.AppSettings["OrgURL"].ToString());
            HomeRealmUri = null;
            Credentials = new ClientCredentials();
            Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
            DeviceCredentials = new ClientCredentials();
            _serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, DeviceCredentials);
            _service = (IOrganizationService)_serviceProxy;

Note: Generally if you are using Network credentials for creating organization service, you may not able to create the organization service because of web service or aspx pages on different servers or on different port with in the same server.

Network credentials will work only if you hosted your custom pages on same server and same port where CRM hosted.

Hosting custom pages on CRM port is unsupported in MS CRM 2013.

1. If you hosted custom pages on different port, so you have to use user credentials (1st approach) to create an organization service. If you use this approach, you may face an issue on security roles. Because you are creating an organization service using particular credentials(Service Credentials, System Administrator or any one's) security roles will work according to the credentials we have used.
2. If you hosted the custom pages on same port where MS CRM 2013 hosted, according to MS CRM 2013 it is unsupported.

You may like below posts

Improving MS CRM Performance

Performance Center in MS CRM 2013

date and time field behavior in MS CRM

Upsert in MSCRM

Locking mechanism in MS CRM

Ticker Symbol Field in MS CRM

Themes in MS CRM

Enable Tracing in MS CRM

Calculated Field in Dynamics CRM 2015

IME Mode in MS CRM

No comments:

Post a Comment