我们在创建用户时有一个选项是WITHOUT LOGIN指定不应将用户映射到现有登录名。
比如CREATE USER user_name WITHOUT LOGIN;
想问一下大家:
1.这个无登录名的用户到底有什么用?
2.平时我们都用它来做什么?
3.我们在应用程序中访问数据库用的连接字符串都是我们平时登陆数据库的账户么?
PS:我只知道Loginless User可以作为guest用户登录到其他服务器上。官方解释是这样的,请大牛指点:
Loginless Users
It is possible to create a user in the database that is not associated to a login, referred to as a
loginless user.
Prior to SQL Server 2005, if you wanted to allow users to access a database only when a
specifi c application was being used, you used an application role. You created the application
role with a password, and assigned permissions to the application role. Users would then
specify the password for the application role to gain access to the database under the
application role’s security context. Unfortunately, when you connected with the application.
role, SQL Server no longer knew the user issuing commands, which created a problem for
auditing activity.
Loginless users were added to replace application roles. Users still authenticate to the
instance using their own credentials. The user’s login needs access to the database. After SQL
Server changes the user’s context to the database, the user impersonates the loginless user
to gain necessary permissions. Because the user is authenticating to the instance using his or
her own credentials, SQL Server can still audit activity to an individual login even though the
login is impersonating a loginless user.