|
14.04.2010, 11:05 | #1 |
Участник
|
mscrmblog: CRM 4: IFD Authentication using C#
Источник: http://mscrmblog.net/2010/04/14/crm-...-using-csharp/
============== A very common question is: “How do i run a plugin/custom web application against a IFD deployment?” You should use the below code: CrmDiscoveryService disco = new CrmDiscoveryService(); disco.Url = "https://YOUR.IFD.URL/MSCRMServices/2007/SPLA/CrmDiscoveryService.asmx"; RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest(); orgRequest.UserId = @"username"; orgRequest.Password = "password"; RetrieveOrganizationsResponse orgResponse = (RetrieveOrganizationsResponse)disco.Execute(orgRequest); OrganizationDetail orgInfo = null; foreach (OrganizationDetail orgdetail in orgResponse.OrganizationDetails) { if (orgdetail.OrganizationName.Equals("OrgName")) { orgInfo = orgdetail; break; } } if (orgInfo == null) { throw new Exception("The specified organization was not found."); } RetrieveCrmTicketRequest ticketRequest = new RetrieveCrmTicketRequest(); ticketRequest.OrganizationName = orgInfo.OrganizationName; ticketRequest.UserId = @"username"; ticketRequest.Password = "password"; RetrieveCrmTicketResponse ticketResponse = (RetrieveCrmTicketResponse)disco.Execute(ticketRequest); CrmAuthenticationToken sdktoken = new CrmAuthenticationToken(); sdktoken.AuthenticationType = 2; sdktoken.OrganizationName = orgInfo.OrganizationName; sdktoken.CrmTicket = ticketResponse.CrmTicket; CrmService service = new CrmService(); service.CrmAuthenticationTokenValue = sdktoken; service.Url = orgInfo.CrmServiceUrl; Code: ifd-service-auth-code.txt Источник: http://mscrmblog.net/2010/04/14/crm-...-using-csharp/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|