How to restrict the sa login to Sybase ASE

Source: Internet
Author: User
Tags sybase time limit


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


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.