Experience your
30 day trial
now!
GET STARTED
In this post, I will try to give you some insights on how CRM authentication works. Modification or updates to CRM authentication pipeline is not supported. This article should be for your reference purpose only.
CRM authentication framework has a pluggable modular structure. Where each supported authentication is plugged into the architecture. CRM supports different way of authenticating users based on the deployment SKU.
In this post I will mainly talk with reference to the on-premise and IFD SKU authentication.
Open the web.config file present on the CRM website in an editor and look at the following.
<crm.authentication> <!-- Indicates which authentication strategy should be used, strategies are stored in config DB table AuthenticationSettings--> <authentication strategy="OnPremise" /></crm.authentication>
There are two httpModules that CRM registers.
<httpModules> <add name ="MapOrg" type="Microsoft.Crm.MapOrgEngine, Microsoft.Crm, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add name ="CrmAuthentication" type="Microsoft.Crm.Authentication.AuthenticationEngine, Microsoft.Crm, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></httpModules>
Note: These two module are not invoked in case of direct report server access, for example when you use the excel apps to refresh crm data working inside your intranet.
The CRM authentication pipeline is stored in the configuration database (MSCRM_CONFIG) in the AuthenticationSettings and AuthenticationSettingsProperties table.
The below query can be used to view the authentication pipeline.
select a.ConfigurationName, ap.ColumnName, ap.NVarCharColumn from dbo.AuthenticationSettings a, dbo.AuthenticationSettingsProperties apwhere a.id = ap.idand ap.NVarCharColumn like '%<%'
The ConfigurationName gives the authentication strategy determined from the webconfig file and the ColumnName indicates the type of settings that can be loaded. The three types of settings possible are CrmAuthenitcation, CrmPassport and CrmPostAuthentication.
The CRM Online uses the CrmPassport authentication strategy.
Both On-Premise and IFD uses the CrmAuthentication type settings.
IFD has an additional CrmPostAuthentication type settings (pipeline step).
Below is an extract for the pipeline xml used for on-premise CRM system.
<?xml version="1.0"?>
<pipeline xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<step>
<predicate type="Microsoft.Crm.Authentication.UrlPathPredicate, Microsoft.Crm, Version={0}, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<configuration key="pathSdk2007" value="/MSCRMServices/2007/CrmService.asmx" />
<configuration key="pathSdk2007MetadataService" value="/MSCRMServices/2007/MetadataService.asmx" />
<configuration key="pathSdkInternalMetadataService" value="/MSCRMServices/Metadata.asmx" />
<configuration key="pathSdkInternalMetadataService2009" value="/MSCRMServices/2009/Metadata.asmx" />
<configuration key="pathSdk2009" value="/MSCRMServices/2009/CrmService.asmx" />
</predicate>
<predicate type="Microsoft.Crm.Authentication.HttpMethodPredicate, Microsoft.Crm, Version={0}, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<configuration key="method" value="POST" />
<provider type="Microsoft.Crm.WebServices.Crm2007.MultipleOrganizationSoapHeaderAuthenticationProvider, Microsoft.Crm.WebServices, Version={0}, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<configuration key="authenticationType0" value="0" />
</provider>
</step>
<!-- ommitted for brevity -->
</pipeline>
We can see that CRM authentication pipeline is a series of steps each having a set of predicates and a single provider. The predicates decide if the provider is to be applied or not.
The predicates implement the IAuthenticationPredicate interface.
namespace Microsoft.Crm.Authentication{ public interface IAuthenticationPredicate { void Configure( IDictionary<string, string> configuration ); bool Evaluate( HttpApplication application ); }}
The providers implement an IAuthenticationProvider interface.
namespace Microsoft.Crm.Authentication{ public interface IAuthenticationProvider { /// <summary> /// Authenticate an HttpRequest on a specified HttpApplication. /// </summary> /// <param name="application">An instance of HttpApplication.</param> /// <returns>True to indicate the authentication is handled and stop authentication pipeline, false otherwise.</returns> bool Authenticate( HttpApplication application ); void Configure( IDictionary<string, string> configuration ); }}
Each predicate and a provider can have configuration parameters specified as key value pairs as shown in the example extract above.
The authentication step also implements the IAuthenticationProvider interface.
Thus, when a request is received, it passes through the asp.net authentication and then reaches the CRM authentication pipeline. The CRM authentication pipeline calls Authenticate() for each registered step which in-turn calls the Evaluate() on each registered predicate. All predicates need to be evaluated before the registered provider can be executed. If any of the predicates returns false the steps execution is halted and pipeline proceeds with the next step and if all of them return true then the registered provider is executed i.e. the Authenticate() method on the provider gets called. There can only be one provider per step. If the provider returns a true then it implies that the request is handled and authentication succeeded, the pipeline execution stops else the processing continues with the next step.
CRM ships with some built in predicates and providers. Below is the list of some of them with their description.
Cheers,
Shashi Ranjan
Hi,
Thank you very much for that post.
It's very interesting, but my question is: how it's can help me as ISV development of CRM ? Can I participate in the process?
Thanks
Itzik
Deep In The Motherlode… As part of my development work I sometimes need to test applications using both
Hi!
Can someone explain what is SKU?
A SKU or 'Stock Keeping Unit' is a version of a product. Examples are in the next sentence.
I'm wondering how I would assign a range of internal IP's (within the 192.168.1.0-255) range which would use Forms Authentication and the remainder to use the AD authentication.
I need this because I have guest users that VPN in and their IP range is assigned from 192.168.1.100.
From the above it looks like I'll need to modify the pipeline or Evaluate method? I'm not sure.
I think instead of SKU he meant SDK??? I had a difficult time with that.
I'm trying to use CRM (4.0)'s web services. When I compose my request and invoke, I'm getting 401 as a result. Even though I affix to the service proxy a set of Network Credentials.
I've made the CRM instance I'm trying to invoke use Basic Authentication but still no luck. What am I forgetting?