(4.25) Sqlserver registered users can only see their own library Sqlserver have permission to log in users can only see their own libraries have rights

Sqlserver registered users can only see their own libraries have rights

 
Background to the issue: on a company's database server multiple databases, each using a different login names, but when you publish project files to Ftp, Ftp is some information in the client side
Once the client side using the database information in the profile to connect to the database he will be able to see all the databases on the server, although it can not access other databases but there are security risks
Now all I need is to specify the login user can only see and access its own database and other databases can not see, so to find a solution on the Web
 
Copy the code
- create a test database 
the Create Database Test; 
the USE Master 
GO 
- create a login through sp_addlogin 
--TestUser: user login account 
--Test123456: user login password 
the Execute sp_addlogin 'TestUser', 'Test123456' 
- Create a database in the database in Test TestUser account 
- each TestUser as login name 
- the second for the database account TestUser 
the Execute sp_grantdbaccess 'TestUser', 'TestUser' 
- add TestUser account database role for the database owner to 
execute sp_addrolemember 'db_owner', 'TestUser '
Copy the code

 

 
Use "TestUser" account to log in after the SSMS possible to see all database
However, if the database is not accessible Test was prompted not have permission
 
Copy the code
Master the USE 
GO 
- will have permission to view all databases to the Public role, each user can only log in to view the specified database 
- this statement will result if all users without permission to set up a database on the server does not display any database, may affect the normal use 
DENY the tO VIEW dATABASE the any the PUBLIC; 
- ownership database Test to TestUser user 
--TestUser users can view and access the Test database 
ALTER AUTHORIZATION ON dATABASE :: Test tO TestUser
Copy the code

 

"DENY VIEW any DATABASE TO PUBLIC;" if no right to set the default login user can not view any of the databases
 
 
"ALTER AUTHORIZATION ON DATABASE :: Test TO TestUser" after TestUser can only view and access the database Test
 
 
reference:
 
Background to the issue: on a company's database server multiple databases, each using a different login names, but when you publish project files to Ftp, Ftp is some information in the client side
Once the client side using the database information in the profile to connect to the database he will be able to see all the databases on the server, although it can not access other databases but there are security risks
Now all I need is to specify the login user can only see and access its own database and other databases can not see, so to find a solution on the Web
 
Copy the code
- create a test database 
the Create Database Test; 
the USE Master 
GO 
- create a login through sp_addlogin 
--TestUser: user login account 
--Test123456: user login password 
the Execute sp_addlogin 'TestUser', 'Test123456' 
- Create a database in the database in Test TestUser account 
- each TestUser as login name 
- the second for the database account TestUser 
the Execute sp_grantdbaccess 'TestUser', 'TestUser' 
- add TestUser account database role for the database owner to 
execute sp_addrolemember 'db_owner', 'TestUser '
Copy the code

 

 
Use "TestUser" account to log in after the SSMS possible to see all database
However, if the database is not accessible Test was prompted not have permission
 
Copy the code
Master the USE 
GO 
- will have permission to view all databases to the Public role, each user can only log in to view the specified database 
- this statement will result if all users without permission to set up a database on the server does not display any database, may affect the normal use 
DENY the tO VIEW dATABASE the any the PUBLIC; 
- ownership database Test to TestUser user 
--TestUser users can view and access the Test database 
ALTER AUTHORIZATION ON dATABASE :: Test tO TestUser
Copy the code

 

"DENY VIEW any DATABASE TO PUBLIC;" if no right to set the default login user can not view any of the databases
 
 
"ALTER AUTHORIZATION ON DATABASE :: Test TO TestUser" after TestUser can only view and access the database Test
 
 
reference:
 

Guess you like

Origin www.cnblogs.com/gered/p/10983202.html