A2oz

How do I create a login domain user in SQL Server?

Published in Database Administration 2 mins read

You can create a login domain user in SQL Server by using SQL Server Management Studio (SSMS). Here's how:

  1. Connect to your SQL Server instance.
  2. Expand Security -> Logins.
  3. Right-click and select "New Login".
  4. In the "Login - New" dialog box, enter the domain user's name in the format "domain\username".
  5. Select the "Windows Authentication" option.
  6. Click "OK" to create the login.

You can also use Transact-SQL (T-SQL) to create a login domain user:

CREATE LOGIN [domain\username] FROM WINDOWS;

Practical Insights:

  • Server Roles: You can assign server roles to the login, such as sysadmin, to grant specific privileges to the user.
  • Database Roles: You can also assign database roles, such as db_owner, within specific databases to control the user's access to database objects.
  • User Mappings: You need to map the login to a database user for the user to access database objects.

Example:

To create a login for the domain user john.doe from the example.com domain and grant them sysadmin privileges, you would follow these steps:

  1. Connect to your SQL Server instance.
  2. Expand Security -> Logins.
  3. Right-click and select "New Login".
  4. In the "Login - New" dialog box, enter "example.com\john.doe" in the "Login name" field.
  5. Select the "Windows Authentication" option.
  6. Select the sysadmin role under "Server Roles".
  7. Click "OK" to create the login.

Related Articles