CREATE TRIGGER [access_trigger]
ON ALL SERVER
with execute as 'sa' -- needed to query sys.dm_exec_connections table
FOR LOGON
AS
BEGIN
if original_login() not in ('superadmin', 'anothersuperadmin', 'mydomain\admin')
and exists (
select * from sys.dm_exec_connections
where session_id = @@SPID
and client_net_address != '<local machine>' -- allow anyone logging on from local server
and client_net_address not like '102.%' -- allow anyone logging on from 102.x.x.x network
) rollback;
END
GO
ENABLE TRIGGER [access_trigger] ON ALL SERVER
GO