Asp.net 2.0 Membership integration?

This post has 25 Replies | 8 Followers

kmac
Not Ranked
Posts 3
Points 30
By: kmac
Posted: Sun, Feb 18 2007 10:54 PM

If we already have a web site utilizing the asp.net 2.0 membership features, will we be able to "plug in" CS2007 and have it use our existing user schema?  Or will it be hard to integrate into an existing asp.net 2.0 web site?

 

Thanks,

Kmac
 

 
  • Post Points: 20 |
Jose Lema
Top 25 Contributor
Posts 1,878
Points 37,765
CS Developers
By: Jose Lema
Posted: Mon, Feb 19 2007 11:50 AM In reply to

Hi Kmac,

This is one of the scenarios that Morpheus (our recent membership work) is designed for. You should have a couple options:

  1. Keep Community Server and your site in the same database. This has always been a possibility, but can be a bit "ugly" as you're potentially putting two big datastores together.
  2. Point Community Server to your "membership database". This is a new option that Morpheus introduces.

Since Morpheus breaks the database ties between CS and ASP.NET Membership, you can now tell Community Server to use a different database for membership related work. To enable this just follow these steps:

  1. Add a new connection string pointing to your membership (existing site) database
  2. Update your providers (Membership, Profile, and/or Role) to use the new connection string
  3. Run a few sprocs in your Membership Database which allow CS to access Membership data in a way that is more performant

This last step is not optional. With Morpheus we've wrapped the default ASP.NET providers with some bulk "get" support that requires some new stored procedures exist in the membership store. Since, by default, Community Server assumes a single location for your site + membership, we haven't broken these sprocs out into a separate file. Below is the list of sprocs that should be run in your membership database:

  • cs_Membership_GetUsersByName
  • cs_Membership_IsUserNameTaken
  • cs_Membership_RenameUser
  • cs_Membership_ChangePasswordAnswer
  • cs_Membership_ValidatePasswordAnswer
  • cs_Profile_GetPropertiesForUsers
  • cs_Role_Get
  • cs_Roles_CreateRole
  • cs_Roles_UpdateRole
  • cs_Roles_GetRoleIdsForUsers
  • cs_Roles_Get

Finally, Morpheus also enables two CS installations (CS2k7+) to share the same membership. In this case, you wouldn't need to run the sprocs above as both installations would already have them as part of a CS 2007 install.

Hope this helps...

One is glad to be of service...

Jose Lema

 
  • Post Points: 50 |
yoDon
Not Ranked
Posts 16
Points 200
By: yoDon
Posted: Sun, Feb 25 2007 8:23 PM In reply to

Does this mean that the (extra cost) single-sign on ASP.NET membership provider add-on is no longer required with CS2007?

 

 
  • Post Points: 20 |
Ken Robertson
Top 10 Contributor
Posts 5,184
Points 47,485
CS Developers
By: Ken Robertson
Posted: Mon, Feb 26 2007 11:39 AM In reply to
The Forms Authentication module is an SSO module for linking users in another ASP.NET based application to CS.  If you are just having users within CS, it is not required and never has been.
 
  • Post Points: 20 |
mcbeev
Not Ranked
Posts 21
Points 445
By: mcbeev
Posted: Tue, Feb 27 2007 1:12 PM In reply to
Jose Lema:
  1. Add a new connection string pointing to your membership (existing site) database
  2. Update your providers (Membership, Profile, and/or Role) to use the new connection string
  3. Run a few sprocs in your Membership Database which allow CS to access Membership data in a way that is more performant

This last step is not optional. With Morpheus we've wrapped the default ASP.NET providers with some bulk "get" support that requires some new stored procedures exist in the membership store. Since, by default, Community Server assumes a single location for your site + membership, we haven't broken these sprocs out into a separate file. Below is the list of sprocs that should be run in your membership database:

  • cs_Membership_GetUsersByName
  • cs_Membership_IsUserNameTaken
  • cs_Membership_RenameUser
  • cs_Membership_ChangePasswordAnswer
  • cs_Membership_ValidatePasswordAnswer
  • cs_Profile_GetPropertiesForUsers
  • cs_Role_Get
  • cs_Roles_CreateRole
  • cs_Roles_UpdateRole
  • cs_Roles_GetRoleIdsForUsers
  • cs_Roles_Get

 

That list of sprocs we just need to run once in that order ?

 
  • Post Points: 5 |
officialcommunity
Top 75 Contributor
Posts 249
Points 4,320
By: officialcommunity
Posted: Tue, Feb 27 2007 3:01 PM In reply to

I've tried doing this with a fresh install of CS 2007 Beta 1, and am running into some issues (i.e. it doesn't work). Here are the steps I followed:

  1. Create database called CommunityServer30
  2. Add application pool identity to the database as a member of the db_securityadmin, db_ddladmin, db_datareader, and db_datawriter roles
  3. Ran cs_3.0_CreateFullDatabase.sql against the database
  4. Added the application pool identity to the aspnet_Membership_FullAccess, aspnet_Personalization_FullAccess, aspnet_Profile_FullAccess, aspnet_Roles_FullAccess, and aspnet_WebEvent_FullAccess roles
  5. Created the site with the following (not the actual credentials, of course): exec dbo.cs_system_CreateCommunity 'localhost', 'dev', 'admin@officialcommunity.com', 'admin', 'password', 0, 0
  6. Copied over web directory files to the root of the site
  7. Updated the ConnectionStrings.config to point to the new database. At this point, everything works just fine - now to use membership from another database.
  8. Created the indicated sprocs on our membership database.
  9. Added our membership database connection string to connectionstrings.config
  10. Changed Membership connectionStringName to the new connection string in the web.config

At this point, everything breaks. Attempting to view any page on the CS2007 instance results in an exception: "System.Exception: A null MembershipUser is not valid to instantiate a new User".

I'm sure that I'm missing something. We're looking to break the membership out to our membership database, leave roles in the CS database, and split profiling across the two.

Any thoughts?

Thanks,

- Kyle (and the officialCOMMUNITY Team)
 

The officialCOMMUNITY Team
 
  • Post Points: 50 |
mcbeev
Not Ranked
Posts 21
Points 445
By: mcbeev
Posted: Tue, Feb 27 2007 3:11 PM In reply to

Yeah I guess Im in the same spot. I have a cs2007 beta instance up and running changed the connection string to hit my existing memebership tables and updated the membership/profile/roles providers, but I think im stuck at the last step. Especially when I look at cs_Membership_GetUsersByName, the proc wants a username(s) for the second param.

 I guess my question is do I have to run that list of procs for every user that already exists ?

 Is there a script already to do this? or more documentation anywhere ?

 

 
  • Post Points: 20 |
officialcommunity
Top 75 Contributor
Posts 249
Points 4,320
By: officialcommunity
Posted: Tue, Feb 27 2007 3:56 PM In reply to
mcbeev:

 I guess my question is do I have to run that list of procs for every user that already exists ?

 

I think Jose just means that those sprocs need to be created in your membership database. 

The officialCOMMUNITY Team
 
  • Post Points: 20 |
mcbeev
Not Ranked
Posts 21
Points 445
By: mcbeev
Posted: Tue, Feb 27 2007 4:09 PM In reply to
Well I installed a clean install of CS2007 beta 1 to the same database as my existing membership so Im only working with one database. And I just verified that all the sprocs are indeed there.  Is there a different version of these that Im missing ?
 
  • Post Points: 20 |
Jose Lema
Top 25 Contributor
Posts 1,878
Points 37,765
CS Developers
By: Jose Lema
Posted: Tue, Feb 27 2007 5:22 PM In reply to
officialcommunity:

At this point, everything breaks. Attempting to view any page on the CS2007 instance results in an exception: "System.Exception: A null MembershipUser is not valid to instantiate a new User".

I'm sure that I'm missing something. We're looking to break the membership out to our membership database, leave roles in the CS database, and split profiling across the two.

Hi Kyle,

The likely issue is that you created a new user in your CS install that doesn't exist in your membership database. The first-time use can be a bit tricky, especially if you're starting from a clean system. You'll need to be sure that your application names match and that the user you login to CS with actually exists in your membership database (strictly from a username/password viewpoint).

Let me know if that solves the problem...

One is glad to be of service...

Jose Lema

 
  • Post Points: 35 |
Jose Lema
Top 25 Contributor
Posts 1,878
Points 37,765
CS Developers
By: Jose Lema
Posted: Tue, Feb 27 2007 5:25 PM In reply to

Hi mcbeev,

My notes were regarding having a separate membership database. If CS and your membership are stored in the same database, then you shouldn't have to do much configuration. Just make sure that when you create your community (ala cs_system_createcommunity), you use the sample application name as your membership data store.

Hope that helps...

One is glad to be of service...

Jose Lema

 
  • Post Points: 20 |
mcbeev
Not Ranked
Posts 21
Points 445
By: mcbeev
Posted: Wed, Feb 28 2007 12:40 PM In reply to
Thanx Jose, figured it out, the magic is in cs_createcommunity, although It did not for some reason give my existing users any roles. After I ran a query to give them all the everyone role things worked. Now on to try and merge the logins Smile
 
  • Post Points: 5 |
officialcommunity
Top 75 Contributor
Posts 249
Points 4,320
By: officialcommunity
Posted: Wed, Feb 28 2007 6:04 PM In reply to
Jose Lema:

Hi Kyle,

The likely issue is that you created a new user in your CS install that doesn't exist in your membership database. The first-time use can be a bit tricky, especially if you're starting from a clean system. You'll need to be sure that your application names match and that the user you login to CS with actually exists in your membership database (strictly from a username/password viewpoint).

Let me know if that solves the problem...

Thanks Jose, that seems to have done the trick.

Cheers,

-Kyle 

The officialCOMMUNITY Team
 
  • Post Points: 5 |
officialcommunity
Top 75 Contributor
Posts 249
Points 4,320
By: officialcommunity
Posted: Fri, Mar 2 2007 1:21 PM In reply to

Hi Jose,

I have another question about Morpheus and membership integration.

We're currently running CS 2.0 and have it integrated with our own single sign-on provider (using the ASP.NET provider model). Due to the constraints of CS 2.0, this means having two membership providers defined in the web.config. Also, when creating a new single sign-on account, we have to manually create the CSUser for everything to flow smoothly.

This is a messy solution. What we'd like is to be able to tack our membership provider onto the front end of CS 2007, without having to touch CS, its database, or use the CSMembershipProvider, but it looks like there might still be ties in place. Ideally, we'd like to have the freedom to create our membership provider backing onto MSAccess, and still have it plug in seamlessly to CS (not that we'd ever do anything horrible like that, of course).

I've tried upgrading one of our CS 2.0 sites to 2007. Our single sign-on membership provider is the only one defined in the web.config, application names match in the two databases, and users exist in both databases (including Anonymous and admin users). However, when I try to open the site, I get the error: "Unable to cast object of type 'OfficialCommunity.Security.CommunityMembershipProvider' to type CommunityServer.ASPNet20MemberRole.CSMembershipProvider'."

Could there be something I'm missing that could cause this (maybe there's something else that needs to be done to migrate the site)? Or is CS 2007 still tied to the CSMembershipProvider?

Thanks,

-Kyle 

The officialCOMMUNITY Team
 
  • Post Points: 20 |
Jose Lema
Top 25 Contributor
Posts 1,878
Points 37,765
CS Developers
By: Jose Lema
Posted: Fri, Mar 2 2007 2:51 PM In reply to

Hi Kyle,

Thanks for the question.

Since Beta 1 of CS2k7, we've made some tweaks to Morpheus. One of those tweaks directly addresses the issue you raise. The reason for the cast is that we're trying to execute some sql within the context of your database (which is unknown to us). So, since the ASP.NET membership provider does not support a method to get users in bulk, we defer the call to a provided method but we need to execute it in the context of your membership store. Now, unfortunately, we have *no idea* where your membership store is. And due to medium trust issues, we cannot get to the connectionStringName from the provider entry in web.config. As a result, we need to cast your provider to some known interface to get the appropriate connectionStringName. Since that was the only thing we used the cast for, we've created an IConnectionStringName interface that your provider must implement.

Currently in Beta 1, you'll need your provider to subclass CSMembershipProvider, but in our next Beta, just implementing this simple interface should do the trick.

Does that help?

One is glad to be of service...

Jose Lema

 
  • Post Points: 35 |
Page 1 of 2 (26 items) 1 2 Next > | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com