views:

508

answers:

3

Hi,

I'm in a situation where I need to auto-auth users between an ASP.NET website and WordPress. The idea is once you're logged into the ASP.NET website and if you browse the WP pages your logged in automagically and vice versa.

In ASP.NET I can auth users against WP database but that's all I can think of, so the question is.

-How to enable this by-directional authentication scheme?

-Zubair

A: 

There are two different server side scripts and it is hard to create by-directional authentication. Since WP uses cookies, you might try to authenticate users against cookies. creating a mechanism that check if there is valid WP cookies in users machine and then read from cookies to authenticate users.

Mohamed
+1  A: 

I had a similar problem, where I had an ASP.net application (third party) and a PHP application (built in-house). I have modified the ASP.net application with just a few lines of code, so that it worked like this:

  1. User logs to the ASP.net application
  2. The ASP.net application sets a session cookie (this is automatic)
  3. Modification: the ASP.net adds a row to the database with the session ID (which is in the cookie) and the username
  4. The PHP application reads the ASP.net session cookie and gets the session ID
  5. The PHP application searches the DB for the session ID and if it is found, it automatically associates the session with the username found

I also added an expiry time for the sessions, to minimize impersonation possibilies...

Palantir
This seems doable specially since both .NET and WP are hosted under the same domain so I presume cookie sharing is easier.Since I got no experience in PHP I need to know- how to read ASP.NET session cookies in PHP (sample)?- I saw that WP sets an auth-cookie at login something like '$ABC$XYZ$ABCDEFGHIJKL..', how can ASP.NET read it to pre-auth the same user?
Zubair Ahmed
Here is the overview about cookies. You will also need to figure out the current username and add it to a db table, but it is not a difficult task. http://www.php.net/manual/en/features.cookies.php(PS: if you like my answer, please vote it up, or mark it as accepted)
Palantir
Thanks for help, I think I've found a solution to auto-auth users from ASP.NET -> WP, for the other way around we've decided to put a link to login.aspx page. I'll share the PHP code soon.
Zubair Ahmed
A: 

Hi Zubair, would be great if you are still agreeable in sharing the code for the community I have the same problem don't want to reinvent the wheel. regards, sport at onesportevent.com

eagle779