I want to create an Sql Server Authentication Account, not a user in the database or in the account.
What i mean is that i want to create an account so i can login from it when i start the sql server, using SQL Transaction or using C#.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are only two modes that I know you can use: Windows or SQL Server Authentication. This means you are limited to only two choices: You either use a Windows account, or you create an SQL Server login that you can use to authenticate.
EDIT:
To programmatically create an sql server login, you could use Sql Server Management objects. I notice you didn’t say whether you want to do this from a Windows (desktop) or Web application. To use Sql Server Management to create a login (or do any sort of “management”), the code would need to run with higher privileges – say local or domain account with sufficient privileges to administer the SQL server instance.
You will need to add references to (you could use version 9.0 of the assemblies):
With that, the following code is enough to create an SQL login and also add the user to your target database
You will need to add:
You can add try{} catch{} blocks and plumbing code to make it more robust you would recover gracefully in case of failure