Reprint SQL Server uses trigger implementations to disable SA users from non-native logons

Source: Internet
Author: User

Original Sticker Address:

51580102

The specific methods are:

Create a Trigger

CREATE TRIGGER Forbiddensaon all SERVER with EXECUTE as'SA'For Logonasbegin--Select SA user to restrict: IF Original_login ()='SA'--allow SA to log on natively "" and (select EVENTDATA (). Value ('(/event_instance/clienthost) [1]','NVARCHAR ()')) not in ('<local machine>','127.0.0.1','10.24.15.15') ROLLBACK; END;

and view the link information for SQL Server

SELECT A.[session_id],a.[login_time],a.[host_name],a.[original_login_name],b.[client_net_address]from MASTER.sys.dm_exec_sessions a INNER JOIN MASTER.sys.dm_exec_connections b on a.session_id=b.session_id

Remove the syntax for this trigger

View two views of a trigger database-scoped DDL triggers with Sys.triggers server-scoped DDL triggers with sys.server_triggers

Explanation of the official website

# I haven't seen it yet #

HTTPS://msdn.microsoft.com/zh-cn/library/ms176054 (v=sql.100). aspx

Reprint SQL Server uses trigger implementations to disable SA users from non-native logons

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.