views:

17

answers:

0

Hi,

I am working on some aspnet C# 3.5 webapp. We use IIS7 on our test server.

This webapp communicates with SharePoint 2007 3.0 SP2 by webservices. We have a machineKey in both web.config (the one of the webapp and the one of the Sharepoint site). The two sites are on two different server.

This communication is working fine.

We have also some home-made SSO: the use in the webapp clicks on a link then SharePoint opens in a new window and the user is already logged in. This SSO is managed by a "shared" cookie in both apps (same name, same domain).

<authentication mode="Forms">
      <forms domain="crm.local" 
             enableCrossAppRedirects="true" 
             loginUrl="*** url to login page ***" 
             name=".CrmAuth" 
             protection="All" 
             slidingExpiration="true" timeout="200">
      </forms>

In SharePoint, we developed a RedirectModule which decrypts the auth ticket from the cookie and log the user.

HttpCookie authCookie = app.Request.Cookies[FormsAuthentication.FormsCookieName];

if (authCookie != null)
 {    
   FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);

   FormsIdentity identity = new FormsIdentity(authTicket);
   GenericPrincipal principal = new GenericPrincipal(identity, null);
}

But, all of a sudden, this SSO has broken. When SharePoint tries to decrypt the cookie, an exception is thrown:

[HttpException (0x80004005): unable to validate data]
   System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo, Boolean signData) +1008
   System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo) +91
   System.Web.Security.FormsAuthentication.Decrypt(String encryptedTicket) +246

Nothing has changed on both server. What can be the cause? What can I do to fix it?