locked
cant retrive orngnizations help me RRS feed

  • Question

  • test.refrence.

    CrmDiscoveryService discoveryService = new test.refrence.CrmDiscoveryService();

    discoveryService.UseDefaultCredentials =

    false;

    discoveryService.Url =

    String.Format(

     

    "http://{0}:{1}/MSCRMServices/2007/{2}/CrmDiscoveryService.asmx",

    _hostname, _port,

    "AD");

     

    NetworkCredential crd = new NetworkCredential("CrmAdmin", "password", "domain");

    discoveryService.Credentials = crd;



     

    RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();

     

     

    RetrieveOrganizationsResponse orgResponse =

    (

    RetrieveOrganizationsResponse)discoveryService.Execute(orgRequest)


    i get  

    orgResponse.OrganizationDetails.Length =====>>> 0


    not able to retrive orgnizations


    CrmAdmin   is system Administrator in the crm

    • Moved by Donna EdwardsMVP Tuesday, October 20, 2009 4:08 PM (From:CRM Deployment)
    Sunday, October 11, 2009 12:47 PM

Answers

  •    Hi Chandoklow,

        The sample code below demonstrates how to retrieve organizations. This will work for the CRM admin user logged in without change. You can if you want to change the code so that it logs in using the crmadmin username and password as in your code.


        string orgName = "YOURCOMPANYNAME";
        string CRMServer = "YOURSERVER";
        
        // Instantiate and configure the CrmDiscoveryService Web service.
        CrmDiscoveryService discoveryService = new CrmDiscoveryService();
        discoveryService.Credentials = System.Net.CredentialCache.DefaultCredentials;
        discoveryService.Url = "http://" + CRMServer + "/mscrmservices/2007/ad/crmdiscoveryservice.asmx";
        discoveryService.PreAuthenticate = true;
        
        // Retrieve the organization name and endpoint Url from the CrmDiscoveryService Web service.
        RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();
        RetrieveOrganizationsResponse orgResponse = (RetrieveOrganizationsResponse)discoveryService.Execute(orgRequest);
        OrganizationDetail orgInfo = null;

        foreach (OrganizationDetail orgDetail in orgResponse.OrganizationDetails)
        {
            if (orgDetail.OrganizationName.Equals(orgName))
            {
                orgInfo = orgDetail;
                break;
            }
        }

    Hassan.

    Hassan Hussain | http://hassanhussain.wordpress.com/ | http://www.mscrmvirtualusergroup.com/
    Sunday, October 11, 2009 2:58 PM

All replies

  •    Hi Chandoklow,

        The sample code below demonstrates how to retrieve organizations. This will work for the CRM admin user logged in without change. You can if you want to change the code so that it logs in using the crmadmin username and password as in your code.


        string orgName = "YOURCOMPANYNAME";
        string CRMServer = "YOURSERVER";
        
        // Instantiate and configure the CrmDiscoveryService Web service.
        CrmDiscoveryService discoveryService = new CrmDiscoveryService();
        discoveryService.Credentials = System.Net.CredentialCache.DefaultCredentials;
        discoveryService.Url = "http://" + CRMServer + "/mscrmservices/2007/ad/crmdiscoveryservice.asmx";
        discoveryService.PreAuthenticate = true;
        
        // Retrieve the organization name and endpoint Url from the CrmDiscoveryService Web service.
        RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();
        RetrieveOrganizationsResponse orgResponse = (RetrieveOrganizationsResponse)discoveryService.Execute(orgRequest);
        OrganizationDetail orgInfo = null;

        foreach (OrganizationDetail orgDetail in orgResponse.OrganizationDetails)
        {
            if (orgDetail.OrganizationName.Equals(orgName))
            {
                orgInfo = orgDetail;
                break;
            }
        }

    Hassan.

    Hassan Hussain | http://hassanhussain.wordpress.com/ | http://www.mscrmvirtualusergroup.com/
    Sunday, October 11, 2009 2:58 PM
  • thx
    i still get this
    i get  

    orgResponse.OrganizationDetails.Length =====>>> 0

    Sunday, October 11, 2009 3:36 PM
  • Hi Chandoklow,

    I cant think of any reason why you are not getting any organizationdetails. Are their any errors logged? 

    H

    Hassan Hussain | http://hassanhussain.wordpress.com/ | http://www.mscrmvirtualusergroup.com/
    Sunday, October 11, 2009 9:45 PM
  • no nor errors logged?
    Monday, October 12, 2009 12:37 PM
  • Hi Chandoklow

    Did you try updating the web reference and make sure you are selecting 2007 discovery web service (for crm 4).

    Rgds
    PD
    Monday, October 12, 2009 1:07 PM
  • ido that bu its nor resolve the proplem

    and i ateemp to use plugin regestration tool an the tool cannot retrive the orgnization
    Monday, October 12, 2009 3:23 PM