0

Will someone please tell me how to create a user without using membership.createuser() and create user wizard in asp.net? I need to perform an additional insert on an existing table during CreateUser().

Kris Krause
  • 7,304
  • 2
  • 23
  • 26
Krishanu Dey
  • 6,326
  • 7
  • 51
  • 69
  • Please provide more details. Are you using the default membership tables or your own custom tables? Nothing is stopping you from writing your own custom provider or executing straight sql. – Kris Krause Apr 22 '12 at 23:16
  • I'm using default membership tables. my database contains 1 more table (emp_details). this table contains the personal details of the employees."UserId" attribute of aspnet_membership table is the foreign key & primary key of the emp_details table. i want to create a new employee entry in emp_details table along with a entry in default membership tables using my custom sql commands, so that i can wrap all sql commands within a transaction. – Krishanu Dey Apr 24 '12 at 20:37

1 Answers1

0

Here are two ways to go:

Implement your own custom membership provider. This is easier than you think and pretty straight forward. There are plenty of articles around.

or

To save you some time... implement your own custom membership provider and inherit from the SqlMembershipProvider class. In the subclass you will mostly just "forward" the calls to the base class except for in the CreateUser method. In this case you can let the base class do most of the work and then perform your custom insert. However, since it does need to be in one transaction (per your comment above) then things might be a little hairy... and you would possibly have to reimplement the CreateUser method in your subclass.

http://msdn.microsoft.com/en-us/library/system.web.security.sqlmembershipprovider.aspx

Note: I am on a bus right now via Wifi, but I am almost tempted to write this for you if you include the emp_details schema for me. Are you using straight ADO.NET or something else?

Kris Krause
  • 7,304
  • 2
  • 23
  • 26