SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Blocking Users by IP


Blocking Users by IP

Author
Message
Paul Paiva
Paul Paiva
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1043 Visits: 265
Good job, Brian. I will definitely use this.

- Paul

http://paulpaivasql.blogspot.com/
K. Brian Kelley
K. Brian Kelley
Keeper of the Duck
Keeper of the Duck (25K reputation)

Group: Moderators
Points: 25244 Visits: 1917
RBarryYoung (3/9/2009)
Great article, Brian. Is the Client_Host ip information still available about a session later on, or would I need to store it from a Logon Trigger like yours if I needed that?


It's also available in sys.dm_exec_connections in the column client_net_address.

K. Brian Kelley
@‌kbriankelley
er.imran.it
er.imran.it
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 37
Hey I ran this and my DB is blocked. Help me out my system giving myself error
Galina Ignatenko
Galina Ignatenko
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 12
It should
er.imran.it
er.imran.it
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 37
Any resolution???? I am not good in DB.. Plz help....
K. Brian Kelley
K. Brian Kelley
Keeper of the Duck
Keeper of the Duck (25K reputation)

Group: Moderators
Points: 25244 Visits: 1917
er.imran.it (3/9/2009)
Any resolution???? I am not good in DB.. Plz help....


If you are logged on to the same computer as SQL Server, then use SQLCMD with the following flags:

SQLCMD -A -E



This forces SQLCMD to connect to the DAC as your Windows account. From there you should be able to drop or disable the trigger as given in the article.

K. Brian Kelley
@‌kbriankelley
RBarryYoung
RBarryYoung
SSC-Dedicated
SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)SSC-Dedicated (35K reputation)

Group: General Forum Members
Points: 35628 Visits: 9518
K. Brian Kelley (3/9/2009)
RBarryYoung (3/9/2009)
Great article, Brian. Is the Client_Host ip information still available about a session later on, or would I need to store it from a Logon Trigger like yours if I needed that?


It's also available in sys.dm_exec_connections in the column client_net_address.

Hah! That's great, Brian. I've seen this question (how can to get a session's IP address) asked many times without hearing an answer. Thanks.

-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
marklegosz
marklegosz
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1396 Visits: 1180
er.imran.it (3/9/2009)
Any resolution???? I am not good in DB.. Plz help....


Probably shouldn't have run the code then.
Ken Shapley
Ken Shapley
SSC-Enthusiastic
SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)SSC-Enthusiastic (116 reputation)

Group: General Forum Members
Points: 116 Visits: 173
This is good stuff. I'm learning. It's got me thinking how an attacker could ompromise our web servers and launch an attack against the SQL Server.
Lonely Rogue
Lonely Rogue
Say Hey Kid
Say Hey Kid (669 reputation)Say Hey Kid (669 reputation)Say Hey Kid (669 reputation)Say Hey Kid (669 reputation)Say Hey Kid (669 reputation)Say Hey Kid (669 reputation)Say Hey Kid (669 reputation)Say Hey Kid (669 reputation)

Group: General Forum Members
Points: 669 Visits: 438
Thanks for the post Brian.

However, I am stuck with few issues. Hope you could throw some light on them and clarify .

1. I executed the Step to insert <local machine< into ValidIP table and still i am not able to connect from my local machine, bcoz of trigger execution.

2. I changed the trigger to capture the @IP value in troubleshooting the above said issue. Below is my code:

CREATE TRIGGER tr_logon_CheckIP
ON ALL SERVER
FOR LOGON
AS
DECLARE @IP NVARCHAR(15),@SqlCmd NVARCHAR(100);
SET @IP = (SELECT EVENTDATA().value('(/EVENT_INSTANCE/ClientHost)[1]', 'NVARCHAR(15)'));
INSERT INTO dbo.ValidIP (IP) VALUES (@IP);
BEGIN
IF IS_SRVROLEMEMBER('sysadmin') = 1
BEGIN

IF NOT EXISTS(SELECT IP FROM DBAWork.dbo.ValidIP WHERE IP = @IP)
ROLLBACK;
END;
END;
GO

But this is not inserting any @IP value in the ValidIP table. Does triggers have constraint of not inserting any value into the tables in execution.

3. If @IP value can't be inserted into the table ,as desired, is there any other way to see the output of EventData() or IP later.

Thanks in advance!!
Vampire

--In 'thoughts'...
Lonely Rogue
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search