Guest User

Untitled

a guest
Oct 22nd, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. var organizationUri = new Uri(ConfigurationManager.AppSettings["CRMServerUrl"]);
  2.  
  3. //Client credentials
  4. var credentials = new ClientCredentials();
  5. credentials.UserName.UserName = @"<user>";
  6. credentials.UserName.Password = "<password>";
  7. // Use the Microsoft Dynamics CRM Online connection string from the web.config file named "CrmConnectionStr".
  8. using (OrganizationServiceProxy _service = new OrganizationServiceProxy(organizationUri, null, credentials, null))
  9. {
  10. Response.Write("Connected");
  11. }
  12.  
  13. <add key="CRMServerUrl" value="http://XXXXX/XRMServices/2011/Organization.svc" />
  14. <add key="username" value="<user>" />
  15. <add key="password" value="<password>" />
  16.  
  17. using Microsoft.Xrm.Client;
  18. using Microsoft.Xrm.Sdk.Client;
  19. using Microsoft.Xrm.Sdk;
  20. using Microsoft.Xrm.Sdk.Query;
  21. using Microsoft.Xrm.Client.Services;
  22.  
  23. string connectionString = "Url=https://your_orgnisation.crm5.dynamics.com; Username=user_name; Password=your_password;";
  24. CrmConnection connection = CrmConnection.Parse(connectionString);
  25. OrganizationService organisationservice = new OrganizationService(connection);
  26.  
  27. <connectionStrings>
  28. <add name="CrmConnStr" connectionString="!SEE EBELOW!"/>
  29. </connectionStrings>
  30.  
  31. // parameter is the name of the connection string
  32. // NOTE: These "setup" declarations are slow, reuse them as much as possibile
  33. var connection = new CrmConnection("CrmConnStr");
  34.  
  35. var service = new OrganizationService(connection);
  36. var context = new CrmOrganizationServiceContext(connection);
  37.  
  38. "Url=http[s]://serverurl/organization; Domain=DOMAIN; Username=USERNAME; Password=PASSWORD"
  39. <!-- https is always nice, but it's not mandatory in this case -->
  40.  
  41. "Url=https://org.server.url; Username=USERNAME; Password=PASSWORD"
  42. <!-- https is of course mandatory here -->
  43. <!-- 'DOMAIN=...' part is not needed because of ADFS -->
  44.  
  45. //Client credentials
  46. var credentials = new ClientCredentials();
  47. credentials.UserName.UserName =ConfigurationManager.AppSettings["username"].toString();
  48. credentials.UserName.Password =ConfigurationManager.AppSettings["password"].toString();
  49.  
  50. ClientCredentials Credentials = new ClientCredentials();
  51. Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
  52.  
  53. Uri OrganizationUri = new Uri("http://XXXXX/XRMServices/2011/Organization.svc");
  54. Uri HomeRealmUri = null;
  55. using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null))
  56. {
  57. IOrganizationService service = (IOrganizationService)serviceProxy;
  58. }
Add Comment
Please, Sign In to add comment