tags:

views:

37

answers:

2

Hello,

So when your using ASP.NET Wizards to create a login, it uses a set of auto generated tables using the aspnet_regsql.exe tool...

When you create a user using the wizard it generates a very long userID "a40cf936-1596-4560-a26c-450792e2c8c0" I want to add users using another program that connects to this database... but how does visual studio auto-generate this ID. I want to auto-generate it as well

Any ideas? Thanks in advance. -Scott

+1  A: 

As Frank said, you should be using the MembershipProvider interface.

To directly answer your question, 99% chance that number is simply a GUID. To get one is as simple as:

string idText = System.Guid.NewGuid().ToString();

EDIT: Just to make it clear though, I am not recommending this. There are probably other dependencies, rights and roles across different tables that you aren't properly implementing if you don't use the proper api calls. You should look here instead.

Serapth
Actually, it's 100% chance that it's a GUID, since that is what the ASP.NET auth provider uses for user keys.
GalacticCowboy
Also, +1 for your edit - unless you *know* what you are doing, don't do it manually!
GalacticCowboy
Thank you for the quick response. This is very helpful, as I will be altering the database outside of asp.net, the only option I see is doing it manually, Thank you very much : )
Scott
A: 

Download .Net Reflector and look at the source for AspNetMemembershipProvider. You can probably find all the SQL calls you need in there. Furthermore, I think you may be able to instantiate the class outside of ASP.NET. There is a method, AspNetMembershipProvider.Initialize(), which you can call to initialize based on what you would have had in the config file. The parameters to Initialize() is not obvious, but disassemble it in reflector and you'll figure it out.

Frank Schwieterman
Thanks.. I will be looking into this
Scott