C# .NET Syslog Server with SQL
By chrisg | September 16, 2007
So often, code gets written to ’scratch an itch’. In this case, I had a little VPN/Firewall appliance, a Cyberguard Snapgear device. This little Linux based device can send events such as when a VPN client connects, or Packet Filter firewall messages to a Syslog server.At first I used a free syslog service that recorded messages to a text file, but I felt it would be better for there to be a .NET service that recorded to an SQL database, and that the source should be available under a BSD style license.
Topics: .NET, SQL | No Comments »
Using the FileSystemWatcher class
By chrisg | September 12, 2007
Among the many very useful and powerful features of the .NET System.IO namespace is the FileSystemWatcher class. This fascinating class allows your apps to monitor changes to folders or files.
The MSDN reference for this class is here: http://msdn2.microsoft.com/en-us/library/system.io.filesystemwatcher(vs.80).aspx
The OnChanged event handler will detect changes in file-attributes, file creation, and file deletion.
The OnRenamed event handler will detect a file rename, and also a cut-and-paste/move operaton
In this example, we are going to present a very simple system-tray application that watches the file-system for file-changes and displays them as a pop-up list.
Read the rest of this entry »
Topics: .NET | No Comments »
Checking for execute permission on a stored procedure on SQL Server 2000
By chrisg | September 12, 2007
A quick piece of SQL Frederick wrote for the sake of some self-test procedures we were working on recently…
This snippet of code allows you to see if you have permission to execute a stored procedure without actually executing it:
declare @publicId int, @myId int, @SPname varchar(64)
select @publicId=uid, @myId=user_id() from sysusers where name=’public’
select @SPname = ‘my_stored_proc’
select case when (o.uid in (@publicId, @myId) or p.type is not null)
then ‘Y’ else ‘N’ end ‘CanExecuteSP’
from sysobjects o
left join sys.database_permissions p
on p.type=’EX’
and p.major_id=o.id
and p.grantee_principal_id in (@publicId, @myId)
and p.state=’G’
where o.type=’P’
and o.name=@SPname
this code returns ‘Y’ if it can execute, ‘N’ if not, returns nothing if SP doesn’t exist
Topics: SQL | No Comments »