Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-03-02
1
Medium Priority
?
609 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 1000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This is a walkthrough guide I wrote whilst upgrading my on-premise MS Dynamics CRM 3.0 deployment to 4.0. This covers the actual installation of the product to a working level for my system, I ran into a lot of issues that the steps below fixed so h…
Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part III
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

650 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