SQL Server user account in the security database, you can control the user's permission

Today, the company SQL Server database, found a SQL Server user account "DemoUser":

 

"DemoUser" sysadmin role not in the database server:

 

"DemoUser" made in the database "TestDB" the user mapping, the mapping database account, also known as "DemoUser", the default SCHEMA is "dbo":

 

"DemoUser" does not own any SCHEMA in the database "TestDB":

 

"DemoUser" no db_owner permissions in the database "TestDB":

 

But the strange thing is, "DemoUser" to connect to the database "TestDB", was able to execute a stored procedure under the src SCHEMA "[src] [SP_ShowUsers].":

 

This is very strange, why SQL Server account "DemoUser" is not a database server administrator (sysadmin), there is no database "TestDB" the db_owner permission, nor has the src SCHEMA, but can be successfully executed " EXEC [src]. [SP_ShowUsers] ", the stored procedure?

 

Later I found out that "DemoUser" own database "TestDB" The EXECUTE permission:

We can see that by default, this window above screenshot, left Securables option after opening the right of the list is empty, we might consider "DemoUser" no permissions database "TestDB", ah?

In actual fact, we click on the Search button in the upper right corner:

Then select All objects of the types:

Then hook on Databases:

Then we will find that the window list, there have been privileged user "DemoUser" has in the database "TestDB", which in the window below the Explicit tab, we can see the "DemoUser" own database "TestDB" the EXECUTE permissions:

The following window Effective Permissions tab also lists "DemoUser" have, among them the EXECUTE permission:

 

The database "TestDB" the EXECUTE privileges, you can also give users "DemoUser" with the following SQL statement:

USE [TestDB]
GRANT EXECUTE TO [DemoUser]

 

As long as the account has a SQL Server database EXECUTE permission, then the account can execute a stored procedure on the corresponding database, which is why this article SQL Server account "DemoUser" can perform the cause of stored procedures in the database "TestDB".

 

So many factors affect the behavior of a SQL Server account, and the account has permission to the SQL Server database is one very important factor.

 

Guess you like

Origin www.cnblogs.com/OpenCoder/p/11165754.html