Posts

Showing posts from November, 2015

Audit SQL Tables with Trigger

Image
Say , you want to audit every record changes in your database tables and also, you need an easier way to query these data whenever needed, I present you, a sample SQL trigger for inserting a new audit record to audit table when an insert, update or delete operation is done on a table row.



First, the audit table: 
CREATE TABLE [dbo].[AuditRecord]( [ID] [int] IDENTITY(1,1) NOT NULL, [AuditType] [char](1) NOT NULL, [TableName] [nvarchar](50) NOT NULL, [OperationTimeStamp] [datetime] NOT NULL CONSTRAINT [DF_AuditRecord_OperationTimeStamp] DEFAULT (getdate()), [UserName] [nvarchar](50) NOT NULL, [Data] [xml] NOT NULL, CONSTRAINT [PK_AuditRecord] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

[AuditType] is either I (Insert), U (Update), or D (Delete)
[Data] is an XML field, which will contain all the IUD operations n…

ASP.NET MVC Fine Grained Identity & Access Control - Part 1

Image
In this series I will explain how I designed a generic claims based access control system ASP.NET MVC 5 with Identity 2.0. Part 2: ASP.NET MVC Fine Grained Identity & Access Control - Part 2

The method I explain here will be useful for applications with moderate complexity, which would require an end user (an admin) to define which resources a particular user has access to. Since I could not find any existing projects with what I want, I bootstrapped my own. I realized that a lot of people want to build something like this, but there are no available resources. Also, please, not that, there is a lot of room for improvement. I will be updating the github repo as I develop the blog post series.




This post targets moderate .NET skill sets. If you have no idea what a claim is, you should first go through that. And see how role based access works. And then come back to claims. Understand the difference and then come back to this post. Also, its nice if you do know what logic gates are. Mo…