18 Temmuz 2012 Çarşamba

CRM Dynamics Online Bağlanma Sınıfı

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Security;
using System.ServiceModel.Description;
using Microsoft.Crm;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Query;
using System.ServiceModel;
using Microsoft.Xrm.Sdk.Messages;

namespace WebApplication2
{
    public class DynamicCrmBaglanma
    {
     
        public static IOrganizationService getCRMOnlineService()
        {
            String userName;
            String password;
            String organizationUrl;
            userName = "deneme@hotmail.com";
            password = "password";
            organizationUrl = "https://deneme.crm4.dynamics.com/XRMServices/2011/Organization.svc";


            Uri OrganizationUri = new Uri(organizationUrl);

            ClientCredentials DeviceCredentials = new ClientCredentials();
//asagıdakı device için bilgileri sdk nin içindeki devicemanager dosyamızı command prompt ta işleme sokarak //buluyoruz.
            DeviceCredentials.UserName.UserName = "11c8kfpjig2pg5z4mn2t6a6zjq";
            DeviceCredentials.UserName.Password = "IA_ARbUy2qi!H0=fRlOc_/`5";

            ClientCredentials credentials = new ClientCredentials();
            credentials.UserName.UserName = userName;
            credentials.UserName.Password = password;

            OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, null, credentials, DeviceCredentials);
            serviceProxy.EnableProxyTypes();

            IOrganizationService _service = (IOrganizationService)serviceProxy;
            return _service;


        }
    }
}

Hiç yorum yok:

Yorum Gönder