views:

37

answers:

2

I am looking to use an open source CMS/blog site like WordPress or Drupal. I need it to work with the ASP.NET Membership I already have running my current website and community site.

I am assuming I need to muck with (hand write) some cookies to pass back and forth. So how would/have you done it? I am looking for creative ideas on how to make this happen smoothly and securely.

+1  A: 

Drupal has a layered and pluggable authentication system, you can use that to connect to any external system for authentication.

As commentor points out below, "external system" may be a bit ambigous.

It does not have to be some XMLRPC, REST, or bus system, it can be anything, from a textfile in a directory to a table filled with legacy accounts in a "local" MySQL database. Point is, this pluggable authentication layer allows for any none Drupal-users-database-table to hook in an allow/disallow authentications/registrations.

berkes
Well, correct me if I'm wrong, but he isn't really authenticating against an external system ... something tells me he doesn't mind hitting the local db for validation, it's just a matter of how does he go about it ... idk, maybe I'm wrong here.
drachenstern
For Drupal, a none-drupal "local DB" counts as an "external system" nonetheless. Maybe I should've been more verbose, correcting that in an edit.
berkes
@berkes +1 comment thanks ;)
drachenstern
A: 

I query the database for the appropriate fields and I use this to create my cookies in C# code, does that help you?

        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
           1,                            // version
           strUser,                      // user name
           DateTime.Now,                 // create time
           DateTime.Now.AddYears(1),     // expire time
           false,                        // persistent
           "my own data" );              // user data
        string strEncryptedTicket = FormsAuthentication.Encrypt( ticket );
        HttpCookie cookie = new HttpCookie( FormsAuthentication.FormsCookieName, strEncryptedTicket );
        Context.Response.Cookies.Add( cookie );

As for the queries to be run, those are straightforward and documented if you have an aspnetdb instance already up with an asp.net app using them, but I could post more code if you need some stuff for accessing those as well. You were asking about the cookie, so this is how I set my cookies in C#

drachenstern
I do this because I have two forms of authentication, but this works for the aspnetdb authentication elsewhere on my system. Once I set the cookie like this manually I'm done authing, and as you can see, it keeps for a year at a time (well yeah, of course you can set the exp time however you like)
drachenstern