Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add user and assign role in aspnet membership through sql servers SP

Tech - asp.net 3.5, Sql server 2005

I have integrate aspnet membership for my webapplication.

I am adding some users (member) from importing excel file.

So how can I add that user and role of that user in aspnet membership tables?

NOTE - I have SP which is used to add member in DB from uploaded excel file, I have wrote insert trriger on membertable.

like image 995
Abhi Avatar asked Jul 10 '12 07:07

Abhi


1 Answers

Do not insert DB records manually. Use .NET's Membership Provider's stored procedures to do that, for example aspnet_Membership_CreateUser and aspnet_Roles_CreateRole.

But better off, use .NET's classes/methods to do that. They encapsulate the whole mechanism for you:

  • Membership Provider
  • Role Provider

First you create a user, then you (optionally) attach role(s) to.

UPDATE December 2015

Folks keep reading this. It's important to know that for a few years now, there is a totally different paradigm, ASP.NET Identity. please use it instead of the old Membership Provider.

like image 128
Ofer Zelig Avatar answered Oct 13 '22 01:10

Ofer Zelig