The solution is as follows:
The validity of the login is validated by using the stored procedure Sp_modifylogin provided by the characteristics of Sybase ASE.
First create a new user with high enough permissions to recover the SA in the future when there is a problem with the server
Next, bind the login script for the SA
use master
go
drop procedure sp_bindlogin
go
Stored procedure names like a system.
create procedure sp_bindlogin
as
begin
declare @hostname varchar(100)
declare @program_name varchar(100)
declare @ipaddr varchar(100)
declare @new datetime
select @hostname = hostname,
@program_name = program_name,
@ipaddr = ipaddr
from master..sysprocesses
where spid = @@spid
Login Machine Limited
if @hostname != '机器名'
begin
shutdown with nowait
end
Login Machine IP Limit
if @ipaddr != '机器IP'
begin
shutdown with nowait
end
Logon Application Qualification
if @program_name in ('SQL_Advantage', 'isql')
begin
shutdown with nowait
end
select @new = getdate()
Logon time limit
if @new >= '20080808'
begin
shutdown with nowait
end
end
go
sp_hidetext sp_bindlogin
go
sp_modifylogin sa, 'login script', sp_bindlogin
go
After processing, the SA can only be native and cannot use isql, SQLADV, and log on to the database before 20080808.
The logic here is free to write.
Here the legality of the validation is not through the processing method is shutdown.
You can replace shutdown with the following stored procedures. So you kill yourself. will not affect the service, just need to do some extra configuration.
drop procedure sp_killme
go
create procedure sp_killme
as
begin
declare @cmd varchar(100)
select @cmd = 'kill ' + convert(varchar(20), @@spid)
exec sp_remotesql 'local', @cmd
end
go
sp_hidetext sp_killme
go