views:

532

answers:

1

I have a database (using Microsoft SQL Server Management Studio Express) that is currently being used quite heavily in a functioning application. I am porting this application over to Windows Authentication rather than the current basic authentication system (or lack thereof) that exists.

The easiest way that I know to set this up involves using the aspnet_reegsql.exe file to set up some tables for me. This obviously creates its basic tables, such as dbo.aspnet_Roles, dbo.aspnet_Users and dbo.aspnet_UsersInRoles.

In the current database, there exist tables named dbo.Users, dbo.UserRole, and dbo.UserRoleMapping. Many of the stored procedures that are written currently for this database rely on these tables.

Is there any gentle way of settling in to the new tables that aspnet_regsql.exe will create? Possibly having it create the configurations on these existing table names, rather than what it is hardwired to do?

Thanks in advance :)

A: 

It sounds like you're confusing two different things. Windows authentication is a way of presenting your Windows login to the database. It works in SSMS by connecting to a database using "Windows Authentication". An application would specify in its connection string:

Integrated Security=SSPI;

instead of a username and password. Both of these options send your current Windows credentials to the database. An example windows login is yourlaptop\chris.

On the other side, aspnet_regsql.exe sets up up a bunch of tables that allow the predefined Microsoft "forms authentication" to work. For example, those tables are required for the login control. When using the aspnet_regsql controls, you typically work with forms authentication. You log on by entering your username and password on a webform. See this site for more membership examples.

Andomar
Maybe I am blurring the line between topics, but does setting the db up with the aspnet_regsql and hooking that up in your web.config file not enable you to perform role operations on those tables? IE Roles.IsUserInRole(user, role) is used quite extensively. Without running the aspnet_regsql, the tables would probably not be set up in the correct fashion for these functions to keep working. Is this a mistake in my thinking?
Can you give some more details about how you use Roles.IsUserInRole(user, role)? An example maybe?
Andomar
Sure. I have three hierarchies of roles. Let's say Admin, Manager and User. Upon loading a page, I check for the correct privileges and authorize the user. Much of the time, I end up calling User.IsInRole(role), instead. That way I get the current user for this session. Once authorized, I load the correct forms and I'm on my way.
Alright-- so you basically want to migrate from the old user tables to the aspnet_regsql user tables?
Andomar
Pretty much, yes. However I'm hoping to find a way to not break everything in the process (stored procedures, in-code calls). This seems pretty improbable. I'm thinking I'll probably need to somehow have the tables set up with my current table names, so as to not completely ruin the stored procedures (although they'll probably still need a lot of work).
You could create a C# program to copy the old usernames to the ASP.NET strore, for example CreateUser http://msdn.microsoft.com/en-us/library/d8t4h2es.aspx. The other way round seems impossible, as I don't think ASP.NET has a way for you to retrieve a user's password.
Andomar