得到域认证下的IOrganizationService
private IOrganizationService GetOrgService() { Uri orgServiceUri = new Uri("http://xxxx:5555/orgname/XRMServices/2011/Organization.svc"); ClientCredentials credentials = new ClientCredentials(); credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; OrganizationServiceProxy crmServiceProxy = new OrganizationServiceProxy(orgServiceUri, null, credentials, null); IOrganizationService crmService = (IOrganizationService)crmServiceProxy; return crmService; }
使用 用户名密码方式下的IOrganizationService
private IOrganizationService GetOrgService() { Uri orgServiceUri = new Uri("http://xxxx:5555/orgname/XrmServices/2011/Organization.svc"); ClientCredentials clientCredentials = new ClientCredentials(); clientCredentials.Windows.ClientCredential = new NetworkCredential("username", "password", "domain"); OrganizationServiceProxy proxy = new OrganizationServiceProxy(orgServiceUri, null, clientCredentials, null); service = (IOrganizationService)proxy; return service ; }