You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Microsoft Dynamics 365获取组织列表时遇organizationName异常求助

Troubleshooting the DiscoveryServiceFault When Retrieving Dynamics 365 Organizations

Hey there, let's work through the organizationName-related DiscoveryServiceFault you're hitting when running your organization retrieval code. First, here's the code you're using for reference:

var clientCredentials = new ClientCredentials(); 
clientCredentials.Windows.ClientCredential.Domain = "domain"; 
clientCredentials.Windows.ClientCredential.UserName = "user"; 
clientCredentials.Windows.ClientCredential.Password = "password"; 

var discoveryUri = new Uri(String.Format("http://{0}/XRMServices/2011/Discovery.svc", "10.20.30.40")); 
var discoveryServiceProxy = new DiscoveryServiceProxy(discoveryUri, null, clientCredentials, null); 

discoveryServiceProxy.Authenticate(); 
var retrieveOrganizationResponse = (RetrieveOrganizationsResponse)discoveryServiceProxy.Execute(new RetrieveOrganizationRequest()); 

Here are the most common fixes for this issue:

1. Add Explicit Filters to Your RetrieveOrganizationRequest

The default empty RetrieveOrganizationRequest might not play nicely with your environment's configuration. Try adding specific parameters to clarify what you're requesting:

var orgRequest = new RetrieveOrganizationRequest
{
    // Request the current release version of organizations
    Release = OrganizationRelease.Current,
    // Use default access type
    AccessType = EndpointAccessType.Default,
    // Optional: If you know the exact org name, uncomment this line
    // OrganizationName = "YourTargetOrganization"
};

var retrieveOrganizationResponse = (RetrieveOrganizationsResponse)discoveryServiceProxy.Execute(orgRequest);

2. Validate Authentication & Permissions

Even though you're calling Authenticate(), there might be permission gaps or proxy initialization issues:

  • Make sure the user account you're using has the Discovery Service Access privilege in Dynamics 365. You can check this in the Dynamics Admin Center under Security > Users > [Your User] > Security Roles.
  • Wrap the proxy in a using block to ensure proper resource disposal, which often resolves flaky connection issues:
using (var discoveryServiceProxy = new DiscoveryServiceProxy(discoveryUri, null, clientCredentials, null))
{
    discoveryServiceProxy.Authenticate();
    var orgRequest = new RetrieveOrganizationRequest();
    var retrieveOrganizationResponse = (RetrieveOrganizationsResponse)discoveryServiceProxy.Execute(orgRequest);
}

3. Verify Your Discovery Service URI

Double-check that your URI is correct and reachable:

  • For on-premises instances, confirm 10.20.30.40 is accessible from your machine, and that navigating to http://10.20.30.40/XRMServices/2011/Discovery.svc in a browser loads the WSDL page (you'll need to log in with the same domain/password you're using in code).
  • If you're targeting an online environment, the URI should follow the format https://disco.crm[region].dynamics.com/XRMServices/2011/Discovery.svc (adjust the region code as needed).

4. Check SDK and Server Version Compatibility

Mismatched versions between your Dynamics 365 SDK assemblies and the on-premises server can trigger unexpected faults. Ensure the SDK version you're referencing in your project matches the version of your Dynamics 365 server exactly.


内容的提问来源于stack exchange,提问作者Raul Mercado

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 04:08:00