?
Solved

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

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
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…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

762 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