Search code examples
asp.netuserid

Manually Add a User to Database ASP.NET?


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


Solution

  • 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.