Create a Login
This topic describes how to create a login in SQL Server 2014 by using SQL Server Management Studio or Transact-SQL. A login is the identity of the person or process that is connecting to an instance of SQL Server.
In This Topic
-
Before you begin:
-
To create a login, using:
-
Follow Up: Steps to take after you create a login
A login is a security principal, or an entity that can be authenticated by a secure system. Users need a login to connect to SQL Server. You can create a login based on a Windows principal (such as a domain user or a Windows domain group) or you can create a login that is not based on a Windows principal (such as an SQL Server login).
Note
|
|---|
|
To use SQL Server Authentication, the Database Engine must use mixed mode authentication. For more information, see Choose an Authentication Mode. |
As a security principal, permissions can be granted to logins. The scope of a login is the whole Database Engine. To connect to a specific database on the instance of SQL Server, a login must be mapped to a database user. Permissions inside the database are granted and denied to the database user, not the login. Permissions that have the scope of the whole instance of SQL Server (for example, the CREATE ENDPOINT permission) can be granted to a login.
To create a SQL Server login
-
In Object Explorer, expand the folder of the server instance in which you want to create the new login.
-
Right-click the Security folder, point to New, and select Login….
-
In the Login – New dialog box, on the General page, enter the name of a user in the Login name box. Alternately, click Search… to open the Select User or Group dialog box.
If you click Search…:
-
Under Select this object type, click Object Types… to open the Object Types dialog box and select any or all of the following: Built-in security principals, Groups, and Users. Built-in security principals and Users are selected by default. When finished, click OK.
-
Under From this location, click Locations… to open the Locations dialog box and select one of the available server locations. When finished, click OK.
-
Under Enter the object name to select (examples), enter the user or group name that you want to find. For more information, see Select Users, Computers, or Groups Dialog Box.
-
Click Advanced… for more advanced search options. For more information, see Select Users, Computers, or Groups Dialog Box - Advanced Page.
-
Click OK.
-
-
To create a login based on a Windows principal, select Windows authentication. This is the default selection.
-
To create a login that is saved on a SQL Server database, select SQL Server authentication.
-
In the Password box, enter a password for the new user. Enter that password again into the Confirm Password box.
-
When changing an existing password, select Specify old password, and then type the old password in the Old password box.
-
To enforce password policy options for complexity and enforcement, select Enforce password policy. For more information, see Password Policy. This is a default option when SQL Server authentication is selected.
-
To enforce password policy options for expiration, select Enforce password expiration. Enforce password policy must be selected to enable this checkbox. This is a default option when SQL Server authentication is selected.
-
To force the user to create a new password after the first time the login is used, select User must change password at next login. Enforce password expiration must be selected to enable this checkbox. This is a default option when SQL Server authentication is selected.
-
-
To associate the login with a stand-alone security certificate, select Mapped to certificate and then select the name of an existing certificate from the list.
-
To associate the login with a stand-alone asymmetric key, select Mapped to asymmetric key to, and then select the name of an existing key from the list.
-
To associate the login with a security credential, select the Mapped to Credential check box, and then either select an existing credential from the list or click Add to create a new credential. To remove a mapping to a security credential from the login, select the credential from Mapped Credentials and click Remove. For more information about credentials in general, see Credentials (Database Engine).
-
From the Default database list, select a default database for the login. Master is the default for this option.
-
From the Default language list, select a default language for the login.
-
Click OK.
Additional Options
The Login – New dialog box also offers options on four additional pages: Server Roles, User Mapping, Securables, and Status.
Server Roles
The Server Roles page lists all possible roles that can be assigned to the new login. The following options are available:
User Mapping
The User Mapping page lists all possible databases and the database role memberships on those databases that can be applied to the login. The databases selected determine the role memberships that are available for the login. The following options are available on this page:
Securables
The Securables page lists all possible securables and the permissions on those securables that can be granted to the login. The following options are available on this page:
Status
The Status page lists some of the authentication and authorization options that can be configured on the selected SQL Server login.
The following options are available on this page:
To create a login using Windows Authentication
-
In Object Explorer, connect to an instance of Database Engine.
-
On the Standard bar, click New Query.
-
Copy and paste the following example into the query window and click Execute.
-- Create a login for SQL Server by specifying a server name and a Windows domain account name. CREATE LOGIN [<domainName>\<loginName>] FROM WINDOWS; GO
To create a login using SQL Server Authentication
-
In Object Explorer, connect to an instance of Database Engine.
-
On the Standard bar, click New Query.
-
Copy and paste the following example into the query window and click Execute.
-- Creates the user "shcooper" for SQL Server using the security credential "RestrictedFaculty" -- The user login starts with the password "Baz1nga," but that password must be changed after the first login. CREATE LOGIN shcooper WITH PASSWORD = 'Baz1nga' MUST_CHANGE, CREDENTIAL = RestrictedFaculty; GO
For more information, see CREATE LOGIN (Transact-SQL).
After creating a login, the login can connect to SQL Server, but does not necessarily have sufficient permission to perform any useful work. The following list provides links to common login actions.
-
To have the login join a role, see Join a Role.
-
To authorize a login to use a database, see Create a Database User.
-
To grant a permission to a login, see Grant a Permission to a Principal.
Note