What Is the Security Principal at the Database Level That Represents Your Session?
Submitted by: AdministratorSecurity principal identifies who you are when you interact with the SQL Server. What can do you at the database solely depends on the security principal that represents you. So it is very important to know your security principal at the database level.
What is the database level security principal of your session? The answer is simple - the user name in the current database that has been mapped to your login name. For example, if you connects to the server with the login name "sa", and sets "GlobalGuideLineDatabase" as the current database, SQL Server will map "sa" to a user name defined in "GlobalGuideLineDatabase" based on some logics. That mapped user name is your security principal for "GlobalGuideLineDatabase" at the database level.
On a Unix system, there is a nice command called "whoami" which returns your security principal on the system. SQL Server provides a similar function called User_Name(), which returns your security principal (a user name mapped to the login name) at the database level. Try it by following this tutorial example:
PRINT Suser_Sname();
GO
sa
USE GlobalGuideLineDatabase;
GO
-- Find out your security principal at the database level
PRINT User_Name();
GO
dbo
This example shows you that "dbo" is user name in "GlobalGuideLineDatabase" that mapped to
Submitted by: Administrator
What is the database level security principal of your session? The answer is simple - the user name in the current database that has been mapped to your login name. For example, if you connects to the server with the login name "sa", and sets "GlobalGuideLineDatabase" as the current database, SQL Server will map "sa" to a user name defined in "GlobalGuideLineDatabase" based on some logics. That mapped user name is your security principal for "GlobalGuideLineDatabase" at the database level.
On a Unix system, there is a nice command called "whoami" which returns your security principal on the system. SQL Server provides a similar function called User_Name(), which returns your security principal (a user name mapped to the login name) at the database level. Try it by following this tutorial example:
PRINT Suser_Sname();
GO
sa
USE GlobalGuideLineDatabase;
GO
-- Find out your security principal at the database level
PRINT User_Name();
GO
dbo
This example shows you that "dbo" is user name in "GlobalGuideLineDatabase" that mapped to
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How To Get the Definition of a View Out of the SQL Server? |
☺ | What Happens If Strings Are Casted into Wrong Code Pages in MS SQL Server? |
☺ | PHP MSSQL - How To Display a Past Time in Days, Hours and Minutes? |
☺ | How To Create a View on an Existing Table in MS SQL Server? |
☺ | How To Select All Columns of All Rows from a Table with a SELECT statement in MS SQL Server? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |