Microsoft Dynamics customer portal accelerator integration with JASIG CAS authentication through .net CAS client
Microsoft Dynamics Customer Portal 2011 is packaged and targeted heavily at CRM online customers and the documentation encourages customers to use windows live as authentication provider. If you have an existing investment in an alternative authentication provider or an Open source Single Sign On framework, you may want to make use of your exiting Authentication framework.
Also for your local development you might like to use Active Directory or an SQL membership provider Database instead of completing the long and complicated windows live set up. You can go about this by following the blog of Shan McArthur on MS Dynamics Customer Portal changes.
In this blog I will attempt to describe the steps and the code changes to Customer Portal 2011 to integrate JASIG CAS SSO. The version of CAS being used as part of this demonstration is 3.4.7 and should work with any other version and the CAS server is deployed on a Tomcat 7 Server.
1. CAS Client Configuration
1. To get started, download .NET CAS Client into C:/tmp/dotnetcasclient. We will use the DotNetCasClien.dll in our customer portal project.
2. Download the customer portal 2011 from dynamics market place into c:/tmp/customerportal2011
3. Open the CustomerPortal solution in VS 2010 and and a reference to CAS client dlls from cas download directory - C:/tmp/dotnetcasclient
4. Open web config file and make the following changes
- Add a new section for casClientConfig in configsections
- Add CasClientConfig details.
If you used to manage seperate config files for various environment you may like to add login and logout URIs to app settings and load the using the key. Replace the server name with your server name
<appSettings>
<add key="SSOLogoutURI" value=https://yourcasserver/cas/logout />
<add key="SSOLoginURI" value=https://yourcasserver/cas/login?service=http://localhost:54130/>
</appSettings>
- Change the authentication mode to form as follows
- Add casclient http module
- Add casclient to webserver modules sections
- Follow the cas client download page to include the diagnostic section in case you want to trouble shoot issues.
In order for the cas server to trust the client you will have to download the server certificate in x509 format and import into the certificate store. Download the certificate from you cas server and save it with .cr extension
Once you have the certificate saved on your desktop with a .crt extension, proceed with the following instructions
PART 1: Add Snap-in
- Open the MMC Console
- Click Start
- Select Run
- Type MMC
- Click OK
- Click File and select Add/Remove Snap-in
- Select Add
- Select Certificates from the Add Standalone Snap-in box and click Add
- Select Computer Account
- Select Local Computer
- Close the Standalone Snap-in box, click Ok in the Add/Remove Snap-in and return to the MMC
Part 2: Install your Intermediate and Root Certificate
- Right-click the Intermediate Certification Authorities folder > All Tasks > Import
- When the Certificate Import Wizard appears, click Next
- Locate the Intermediate Certificate(s) you saved and click Next
This completes the cas client related configuration changes to force in cas client library to do the magic with the HTTP request and response pipeline.
2. Customer Portal changes
1. Open Login.aspx.cs file and change it to look like this to make sure if the user is not authenticated redirect them to CAS for authentication. Session timeout and CAS ticket expiry scenarios are covered though this code in conjunction with the changes we made to the web config file.
Now rebuild the customer portal solution and start it in debug mode when you click on the login link you will be redirected to your cas sso login page.
2. Open Default.master.cs and change the LogoutLink_Click method as follows. We want to cleanly log out the user from the portal and call cas logout to clean up the CAS authentication cookies and expire the authentication ticket.
I have made the following assumptions
- You already have the Customer portal solution imported into your organisation and loaded the initial content via websitecopy.exe
- You have some test contacts in your CRM organisation and the same users exist in your CAS authentication repository ( Whatever repository your CAS server is binding to – AD/SQL Server/Oracle/My SQL/Sun Directory all supported)
- Recompiled xrm so all customisations to your crm organisation are pushed up to all layers.
Comments
Post a Comment