How to disable SQL Server Management Studio for a

2020-02-28 06:33发布

Is there a way to prevent users from getting into SQL Server Management Studio so that they can't just edit table rows manually? They still need to access the tables by running my application.

11条回答
我欲成王,谁敢阻挡
2楼-- · 2020-02-28 06:59

If your application only used stored procedures to modify the data, you could give the end users access to run the stored procs, but deny them access to modify the tables.

查看更多
兄弟一词,经得起流年.
3楼-- · 2020-02-28 07:02

You can use a trigger.

CREATE TRIGGER [TR_LOGON_APP]
ON ALL SERVER 
FOR LOGON
AS
BEGIN

   DECLARE @program_name nvarchar(128)
   DECLARE @host_name nvarchar(128)

   SELECT @program_name = program_name, 
      @host_name = host_name
   FROM sys.dm_exec_sessions AS c
   WHERE c.session_id = @@spid


   IF ORIGINAL_LOGIN() IN('YOUR_APP_LOGIN_NAME') 
      AND @program_name LIKE '%Management%Studio%' 
   BEGIN
      RAISERROR('This login is for application use only.',16,1)
      ROLLBACK;
   END
END;

https://www.sqlservercentral.com/Forums/1236514/How-to-prevent-user-login-to-SQL-Management-Studio-#bm1236562

查看更多
啃猪蹄的小仙女
4楼-- · 2020-02-28 07:03

I would suggest you lock down the database and give appropriate read-only (or other) rights to the user. That way the user can still use management studio to run select queries and such.

If you don't want the user to have any rights at all then you could do that as well.

查看更多
Fickle 薄情
5楼-- · 2020-02-28 07:08

You can deny 'Users' access rights to the ssms.exe executable file, while granting the relevant users/administrators rights to it.

查看更多
\"骚年 ilove
6楼-- · 2020-02-28 07:08

I agree with Jon Erickson as a general rule

  • do not allow any users access to the tables, but only allow access through stored procs
  • do not allow general user accounts access to stored procs, but only the account your app runs under (whether it's an integrated login or SQL login)
查看更多
爷、活的狠高调
7楼-- · 2020-02-28 07:08

Make well usage of Database Roles, if Users should only have SELECT (read) access assign them the db_datareader Role. Even if they login using SSMS they will can execute only SELECT statements.

查看更多
登录 后发表回答