If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > logon trigger

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #16 (permalink)  
Old 11-16-10, 11:47
medamadhu medamadhu is offline
Registered User
 
Join Date: Sep 2010
Posts: 12
Hi Martijnvs,

I tried the new updated procedure with log data into the table but it is not inserting the values in the table.I tried commenting the /*select syb_quit()*/ if that would be the reason but it still doesn't work.Need to do any change??


create procedure sp__checkipaddress
as
begin
--declare variable
declare @ip varchar(12)
if exists(select * from user_info where username=suser_name())
print 'user exists'
else
print 'doesnot exists'


--lookup ipaddress of current process

select @ip = ipaddr from master..sysprocesses where spid=@@spid
select @ip= substring(@ip,1,char_length(@ip)-charindex(".",reverse(@ip)))

--check if ipaddress is in the approved-list
if not exists (select 1 from approved_clients where ipaddress = @ip)
begin
--if not:
--log data into table
insert into client_logging(loginname, source_ip, eventtime)
values (suser_name() , @ip, getdate() )
--and terminate connection
/*select syb_quit()*/
end
return 0

end
go



1> select * from client_logging
2> go
loginname source_ip eventtime
------------------------- --------------- --------------------------

(0 rows affected)

Thanks,
Meda
Reply With Quote
  #17 (permalink)  
Old 11-17-10, 03:23
Martijnvs Martijnvs is offline
Registered User
 
Join Date: Jan 2004
Location: The Hague/Utrecht, NL
Posts: 415
I haven't tried the code myself, so there may be somethign I overlooked.
The script I posted only should log data if an user is not in the approved list and is about to be kicked. If a user is allowed to stay logged in, no data is logged.

You can try some extra debugging to see if the codeblock in which the insert happens is reached by putting a print "sometext"-statement before the insert.
If you run the code and the print is not shown while it should have, there might be somethign wrong with the ipcheck.
__________________
I'm not crazy, I'm an aeroplane!
Reply With Quote
  #18 (permalink)  
Old 11-19-10, 15:57
medamadhu medamadhu is offline
Registered User
 
Join Date: Sep 2010
Posts: 12
Thanks Martijnvs,I am able to log the data now and everything seems to be working fine.Once again i appreciate for your time and patience.

Regards,
Meda
Reply With Quote
  #19 (permalink)  
Old 11-23-10, 03:55
Martijnvs Martijnvs is offline
Registered User
 
Join Date: Jan 2004
Location: The Hague/Utrecht, NL
Posts: 415
no problem, glad I could help .
One last advice: keep an eye on the growth of the loggingtable. Put the table in a userdatabase instead of master if neccesary, it doesn't screw up your ASE-server.
__________________
I'm not crazy, I'm an aeroplane!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On