How to make a logged-in Longin link to SQL Server, you can only see the database that has permissions in the database

Source: Internet
Author: User

In general, login created in SQL Server, regardless of permission size, can see all of the databases in its SQL Server, which can be verified by the following T-SQL

IF EXISTS(SELECT *  fromSys.server_principals SPWHEREName= 'Test')     DROPLOGIN TestGO  CREATELOGIN Test withPASSWORD= 'Test' GO   --Check if test has permission to view any database and connect to SQL Server EXECUTE  asLogin= 'Test'  SELECT Suser_name() LoginName,user_name() Dbusername, Has_perms_by_name (NULL,NULL,'VIEW any DATABASE') Hasviewanydb, Has_perms_by_name (NULL,NULL,'CONNECT SQL') Hasconnectsql REVERT
View Code

Do not map login to database, select Database properties, modify owner for that login, execute

Use theGODENY VIEW any DATABASE to       GO


Note that login to SQL with this login, is the permission of SA, the Permission Control section has not found the method of control temporarily

How to make a logged-in Longin link to SQL Server, you can only see the database that has permissions in the database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.