Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between login and user in sql server [duplicate]

CREATE USER [anc] WITHOUT LOGIN WITH DEFAULT_SCHEMA=[anc]
GO

what is the difference between the user and the login.

i am not clear as to y do we create these kind of users??

like image 561
iims Avatar asked Jul 31 '10 18:07

iims


People also ask

What is the difference between SQL Server login and user?

A Login is an identity used to connect to a SQL Server instance. A User allows you to log into a SQL Server database and is mapped to a Login. So you will need to first create a Login, before you can create a User in SQL Server.

What is the difference between a login and a user?

A Login is used for authentication into a SQL Instance while a User is used for authorization into a SQL Database. Note that Logins are used at the Instance level and Users are used at the Database level. Here is how to create a new Login and User in SQL Server.

What is a login in SQL Server?

A login is a security principal at the scope of the SQL Server instance, and a SQL Server instance can contain numerous databases. There are two main types of logins; Windows authenticated login and SQL Server authenticated login. Simply stated, a login allows you to connect to a SQL Server instance.


2 Answers

Logins are a server wide (instance level) objects. Their correct name is 'server principals' (see sys.server_principals). Server wide privileges are granted to logins, like create database or view server state permissions.

Users are a database objects, correctly referred to as 'database principals' (see sys.database_principals). They are the recipients of database permissions, like create table or select.

Ordinarily a login is mapped 1-to-1 to a user in each database, via a matching SID, but there are some exception, like all members of the sysadmin fixed server role are always mapped to dbo.

Users without login are a specific construct for Service Broker remote identities (see Remote Service Bindings) and for code signing. You should never have to create one in any other context, and if you do, you're likely doing it wrong. Users without login are never meant to be impersonated.

like image 72
Remus Rusanu Avatar answered Sep 25 '22 08:09

Remus Rusanu


A login is a login account for the entire SQL Server instance - an instance can contain numerous databases.

A user is defined at the database level, and is associated with a login to provide interactive access (privileges providing).

like image 34
OMG Ponies Avatar answered Sep 21 '22 08:09

OMG Ponies