Web Form (IFD) Authentication
![]() |
[Applies to: Microsoft Dynamics CRM 4.0]
Internet-facing deployment (IFD) uses Active Directory to authenticate a user. The user can access Microsoft Dynamics CRM from an internal network or from the Internet. Either way, the user must have an account in Active Directory.
The process to authenticate a user under IFD resembles Active Directory authentication. However, the licensing model specified when you access the CrmDiscoveryService Web service is a Microsoft Service Providers License Agreement (SPLA). In addition, a ticket must be obtained and set in the CrmAuthenticationTokenValue property value instance of the CrmService instance.
The IFD authentication process involves the following steps:
- Create an instance of the CrmDiscoveryService Web service proxy.
- (1,2) (Optional) Obtain a list of available organizations from the CrmDiscoveryService Web service. Find the target organization in the list.
- (3,4) Obtain a ticket from the CrmDiscoveryService Web service.
- Create a CrmAuthenticationToken instance and set its AuthenticationType, OrganizationName, and CrmTicket property values.
- (5) Create an instance of the CrmService Web service proxy and call Web service methods.
Example
This process is demonstrated in the following sample code.
[C#]
using System;
using System.Xml;
using System.Text;
using System.Web.Services.Protocols;
// Microsoft Dynamics CRM namespaces.
// Note that the Visual Studio project name is IFD_Authentication.
using IFD_Authentication.CrmSdk;
using IFD_Authentication.CrmSdk.Discovery;
public class IFDConnection
{
// A CrmService reference.
public readonly CrmService CrmService = null;
// URL of the Web application.
public readonly string WebApplicationUrl = String.Empty;
// GUID of the user's organization.
public readonly Guid OrganizationId = Guid.Empty;
/// <summary>
/// Authenticate the user using IFD (Internet Facing Deployment). The class
/// constructor sets the values of the public variables (CrmService, etc).
/// </summary>
/// <param name="organization">Name of the user's organization.</param>
/// <param name="server">Microsoft Dynamics CRM server URL.
/// For example: https://myserver.</param>
/// <param name="domain">Name of the domain hosting the user's system
/// account.</param>
/// <param name="username">User's system account name.</param>
/// <param name="password">User's account password.</param>
public IFDConnection(string organization, string server, string domain,
string username, string password)
{
//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 (orgdetail.OrganizationName == organization)
{
//Retrieve the ticket.
RetrieveCrmTicketRequest ticketRequest =
new RetrieveCrmTicketRequest();
ticketRequest.OrganizationName = organization;
ticketRequest.UserId = domain + "\\" + username;
ticketRequest.Password = password;
RetrieveCrmTicketResponse ticketResponse =
(RetrieveCrmTicketResponse)disco.Execute(ticketRequest);
//Create the CrmService Web service proxy.
CrmAuthenticationToken sdktoken = new CrmAuthenticationToken();
sdktoken.AuthenticationType = 2;
sdktoken.OrganizationName = organization;
sdktoken.CrmTicket = ticketResponse.CrmTicket;
CrmService = new CrmService();
CrmService.CrmAuthenticationTokenValue = sdktoken;
CrmService.Url = orgdetail.CrmServiceUrl;
WebApplicationUrl = orgdetail.WebApplicationUrl;
OrganizationId = orgdetail.OrganizationId;
break;
}
}
}
}
See Also
Concepts
Other Resources
© 2010 Microsoft Corporation. All rights reserved.
