Solved

How can I authenticate to the CrmMetadataService in an IFD environment?

Posted on 2011-03-02
1
600 Views
Last Modified: 2012-06-04
I'm trying to connect to the CrmMetadataService from a custom web service that I am using to run some extensive calculations on data. The environment is CRM 4 installed as an Internet Facing Deployment. I have no trouble using the DiscoverySerbive to issue an authentication token from the CrmService web service. Unfortunately, I'm having trouble configuring the MetaDataService. My Code for the CrmService is as follows:

public static string GetIFDConnection(string organization, string server, string domain, string username, string password, CrmService crmService)
        {
            // Remove any trailing forward slash from the end of the server URL.
            server = server.TrimEnd(new char[] { '/' });

            // Initialize an instance of the CrmDiscoveryService Web service proxy
            CrmDiscoveryService disco = new CrmDiscoveryService();
            disco.Url = server + "/MSCRMServices/2007/SPLA/CrmDiscoveryService.asmx";

            // Retrieve a list of available organizations.
            RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();
            orgRequest.UserId = domain + "\\" + username;
            orgRequest.Password = password;
            RetrieveOrganizationsResponse orgResponse = (RetrieveOrganizationsResponse)disco.Execute(orgRequest);

            // Find the desired organization
            foreach (OrganizationDetail orgdetail in orgResponse.OrganizationDetails)
            {
                if (String.Compare(orgdetail.OrganizationName, organization, true) == 0)
                {
                    //Retrieve the ticket
                    RetrieveCrmTicketRequest ticketRequest = new RetrieveCrmTicketRequest();
                    ticketRequest.OrganizationName = organization;
                    ticketRequest.UserId = domain + "\\" + username;
                    //ticketRequest.UserId = username;
                    ticketRequest.Password = password;
                    RetrieveCrmTicketResponse ticketResponse = (RetrieveCrmTicketResponse)disco.Execute(ticketRequest);

                    // Create the CrmService Web service proxy
                    CrmSdk.CrmAuthenticationToken sdktoken = new CrmSdk.CrmAuthenticationToken();
                    sdktoken.AuthenticationType = 2; // Use IFD Authentication
                    sdktoken.OrganizationName = organization;
                    sdktoken.CrmTicket = ticketResponse.CrmTicket;
                    crmService.CrmAuthenticationTokenValue = sdktoken;
                    return orgdetail.CrmServiceUrl;
                }
            }

Open in new window


I am setting the token and passing back the service endpoint URL. This works great for the CrmService Web service. Can anyone tell me how to do the same thing to configure the MetadataService? Here is what I have so far...

 
public static string GetMetadataIFDConnection(string organization, string server, string domain, string username, string password, CrmService crmService)
        {
            // Remove any trailing forward slash from the end of the server URL.
            server = server.TrimEnd(new char[] { '/' });

            // Initialize an instance of the CrmDiscoveryService Web service proxy
            CrmDiscoveryService disco = new CrmDiscoveryService();
            disco.Url = server + "/MSCRMServices/2007/SPLA/CrmDiscoveryService.asmx";

            // Retrieve a list of available organizations.
            RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();
            orgRequest.UserId = domain + "\\" + username;
            orgRequest.Password = password;
            RetrieveOrganizationsResponse orgResponse = (RetrieveOrganizationsResponse)disco.Execute(orgRequest);

            // Find the desired organization
            foreach (OrganizationDetail orgdetail in orgResponse.OrganizationDetails)
            {
                if (String.Compare(orgdetail.OrganizationName, organization, true) == 0)
                {
                    //Retrieve the ticket
                    RetrieveCrmTicketRequest ticketRequest = new RetrieveCrmTicketRequest();
                    ticketRequest.OrganizationName = organization;
                    ticketRequest.UserId = domain + "\\" + username;
                    //ticketRequest.UserId = username;
                    ticketRequest.Password = password;
                    RetrieveCrmTicketResponse ticketResponse = (RetrieveCrmTicketResponse)disco.Execute(ticketRequest);

                    // Create the CrmService Web service proxy
                    CrmSdk.CrmAuthenticationToken sdktoken = new CrmSdk.CrmAuthenticationToken();
                    sdktoken.AuthenticationType = 2; // Use IFD Authentication
                    sdktoken.OrganizationName = organization;
                    sdktoken.CrmTicket = ticketResponse.CrmTicket;
                    crmService.CrmAuthenticationTokenValue = sdktoken;
                    return orgdetail.CrmMetadataServiceUrl;
                }
            }
            return "";
        }

Open in new window


My thought ws to configure it the same way I did with the CrmService but return the  orgdetail.CrmMetadataServiceUrl instead (see the last lines of the method). I'm still getting a authentication error when trying to contact the MetadataService. Any ideas would be appreciated.

Thanks...
0
Comment
Question by:svcoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
Aftab_Khateeb earned 500 total points
ID: 35480736
Hi, Have you tried instead of Organisation name the URL of the IFD
for e.g. http://yourServerAddress/yourOrgName/mscrmservices....
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question