Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var organizationUri = new Uri(ConfigurationManager.AppSettings["CRMServerUrl"]);
- //Client credentials
- var credentials = new ClientCredentials();
- credentials.UserName.UserName = @"<user>";
- credentials.UserName.Password = "<password>";
- // Use the Microsoft Dynamics CRM Online connection string from the web.config file named "CrmConnectionStr".
- using (OrganizationServiceProxy _service = new OrganizationServiceProxy(organizationUri, null, credentials, null))
- {
- Response.Write("Connected");
- }
- <add key="CRMServerUrl" value="http://XXXXX/XRMServices/2011/Organization.svc" />
- <add key="username" value="<user>" />
- <add key="password" value="<password>" />
- using Microsoft.Xrm.Client;
- using Microsoft.Xrm.Sdk.Client;
- using Microsoft.Xrm.Sdk;
- using Microsoft.Xrm.Sdk.Query;
- using Microsoft.Xrm.Client.Services;
- string connectionString = "Url=https://your_orgnisation.crm5.dynamics.com; Username=user_name; Password=your_password;";
- CrmConnection connection = CrmConnection.Parse(connectionString);
- OrganizationService organisationservice = new OrganizationService(connection);
- <connectionStrings>
- <add name="CrmConnStr" connectionString="!SEE EBELOW!"/>
- </connectionStrings>
- // parameter is the name of the connection string
- // NOTE: These "setup" declarations are slow, reuse them as much as possibile
- var connection = new CrmConnection("CrmConnStr");
- var service = new OrganizationService(connection);
- var context = new CrmOrganizationServiceContext(connection);
- "Url=http[s]://serverurl/organization; Domain=DOMAIN; Username=USERNAME; Password=PASSWORD"
- <!-- https is always nice, but it's not mandatory in this case -->
- "Url=https://org.server.url; Username=USERNAME; Password=PASSWORD"
- <!-- https is of course mandatory here -->
- <!-- 'DOMAIN=...' part is not needed because of ADFS -->
- //Client credentials
- var credentials = new ClientCredentials();
- credentials.UserName.UserName =ConfigurationManager.AppSettings["username"].toString();
- credentials.UserName.Password =ConfigurationManager.AppSettings["password"].toString();
- ClientCredentials Credentials = new ClientCredentials();
- Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
- Uri OrganizationUri = new Uri("http://XXXXX/XRMServices/2011/Organization.svc");
- Uri HomeRealmUri = null;
- using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null))
- {
- IOrganizationService service = (IOrganizationService)serviceProxy;
- }
Add Comment
Please, Sign In to add comment