[Crm] CRM 4.0 : Come creare via codice un account

A differenze del precedente Crm 3.0 , essendo quest'ultimo, multi società, ogni volta che ci collega al servizio del Crm è necessario passargli oltre alle solite credenziali anche un token con il riferimento alla societa (Organization)     

           CrmAuthenticationToken token = new CrmAuthenticationToken();
            token.AuthenticationType = 0; // Use Active Directory authentication.
            token.OrganizationName = "AdventureWorksCycle";
            // Use the global user ID of the system user that is to be impersonated.
            token.CallerId = new Guid("94092D6F-B367-DC11-9C93-0003FFDFCE28");


            CrmService crmService = new CrmService();
            crmService.Url = "http://localhost/MSCRMServices/2007/CrmService.asmx";
            crmService.CrmAuthenticationTokenValue = token;
            crmService.Credentials = System.Net.CredentialCache.DefaultCredentials;


            // Create a new account owned by the impersonated user.
            account account = new account();
            account.name = "Fabrikam";
            Guid accountid = crmService.Create(account);

posted @ lunedì 21 gennaio 2008 22:03

Print
«aprile»
domlunmarmergiovensab
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011