0

I have to use CrmDiscoveryService.asmx for DYNAMICS CRM 2011 because of the compatability to CRM 4.0. I impemented IFD authentification algorithm and now it doesnt works:

I can connect me successfully to CrmDiscoveryService.asmx from Browser (anonymous connection enabled) URL: https://internalcrm.organme>.com:444/mscrmservices/2007/spla/crmdiscoveryservice.asmx

But if I try to get connected with the same URL from ASP.NET - i receive 401 error. Code:

RetrieveCrmTicketRequest crmTicketRequest = new RetrieveCrmTicketRequest();
crmTicketRequest.OrganizationName = OrgUniqueName;
crmTicketRequest.UserId = "bnet"+"\\"+"izz";
crmTicketRequest.Password = "pass";
CrmDiscoveryService discoveryService = serviceHandler.CreateCrmDiscoveryService(crmDiscoveryServiceUrl);
discoveryService.UseDefaultCredentials = true;
RetrieveCrmTicketResponse crmTicketResponse =
(RetrieveCrmTicketResponse)discoveryService.Execute(crmTicketRequest);

//Trust all certificates
System.Net.ServicePointManager.ServerCertificateValidationCallback =
((sender, certificate, chain, sslPolicyErrors) => true);
4

2 回答 2

0

从检索可用组织列表开始可能是有意义的,例如使用 CrmDiscoveryService Web 服务的示例:IFD

// Configure an instance of the CrmDiscoveryService Web service proxy.
CrmDiscoveryService disco = new CrmDiscoveryService();
disco.Url = "https://localhost/MSCRMServices/2007/SPLA/CrmDiscoveryService.asmx";

//Retrieve a list of available organizations from the CrmDiscoveryService Web service.
RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();
// Substitute an appropriate domain, username, and password here.
orgRequest.UserId = domain + "\\" + username;
orgRequest.Password = password;
RetrieveOrganizationsResponse orgResponse = (RetrieveOrganizationsResponse)disco.Execute(orgRequest);

//Find the target organization.
OrganizationDetail orgInfo = null;

foreach (OrganizationDetail orgdetail in orgResponse.OrganizationDetails)
{
    if (orgdetail.OrganizationName.Equals("AdventureWorksCycle"))
    {
        orgInfo = orgdetail;
        break;
    }
}

// Check whether a matching organization was not found. 
if (orgInfo == null)
    throw new Exception("The specified organization was not found.");

//Retrieve a CrmTicket from the CrmDiscoveryService Web service.
RetrieveCrmTicketRequest ticketRequest = new RetrieveCrmTicketRequest();
ticketRequest.OrganizationName = orgInfo.OrganizationName;
ticketRequest.UserId = domain + "\\" + username;
ticketRequest.Password = password;
RetrieveCrmTicketResponse ticketResponse =
    (RetrieveCrmTicketResponse)disco.Execute(ticketRequest);
于 2012-05-08T08:30:12.280 回答
0

正如 paramosh 所说,尝试在发现服务上设置凭据:

discoveryService.Credentials = new System.Net.NetworkCredential("izz", "password", "bnet");

于 2012-05-08T13:36:43.033 回答