Skip to main content

Posts

Showing posts from 2014

How to determine total number of open/active connections in Microsoft sql server

This shows the number of connections per each DB: SELECT DB_NAME(dbid) as DBName, COUNT(dbid) as NumberOfConnections, loginame as LoginName FROM sys.sysprocesses WHERE dbid > 0 GROUP BY dbid, loginame And this gives the total: SELECT COUNT(dbid) as TotalConnections FROM sys.sysprocesses WHERE dbid > 0 If you need more detail, run: sp_who2 'Active'

Custom serialization Using Newtonsoft.Json

When using Newtonsoft. Json to serialize objects, we can avoid few properties from being included in the output for some use case and the same property be included in the serialized output in other cases. There's a feature in the Newtonsoft.Json.NET library, that lets us  determine at runtime whether or not to serialize a particular property of a class / object. During the process of creating a class, we have to include a public method named ShouldSerialize{MemberName} returning a boolean value. Json.NET will call that method during serialization to determine whether or not to serialize the corresponding property of the class. If this method returns true, the property will be serialized; otherwise, it will be ignored. The following illustration shows how this can be achieved. The following is a data definition / class that may be serialized using Newtonsoft.Json.Net public class AuthTypeClaimMapViewModel {     [JsonIgnore]     public bool? _canSerializeName { get;

Restoring a Database using bak files and SQL Scripts alone

The following is the script to restore any database from a .bak file without using Sql Server Management Studio -- The database name in the restored bak file should be the same as the one given here RESTORE DATABASE [authserver] FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL11.LOCAL\MSSQL\Backup\database.bak' WITH FILE = 1, MOVE N'authserver' TO N'C:\Program Files\Microsoft SQL Server\MSSQL11.LOCAL\MSSQL\DATA\database.MDF', MOVE N'authserver_LOG' TO N'C:\Program Files\Microsoft SQL Server\MSSQL11.LOCAL\MSSQL\DATA\database.LDF', NOUNLOAD, REPLACE, STATS = 10 GO

The world is as we see

An extrovertish view of the world around On the eve of a well started thursday, the penultimate day for a long work week, as often seen as this day 27th Feb 2014, I started my journey from my office working my way round to my home which stands farther from my office by approx 497kms. I made my way to the railway station, where we begin onboarding the train's to one's natives that are distant by approx 4hrs travel. My eldritch intuition began ringing within to pull off the strings from office to break for the week a day earlier and reach home to meet my lone parents. I reserved my berth in a train that get its ends loosened from the national capital a day before the ones that typically leave to my home town from my worktown, a sluggish way to get a confirmed birth. Though seemingly easy for an outsider, I have my painful way to kick-start off my travel by hurting myself for a two-and-a-half hour journey by scrambling for a seat to get me kinda comfortable for the next two-an

World Peace day

As a protraction to the world peace day, I wish to present an extemporary propaganda. How about you making a wish now, for an ally or foe or a protagnoist (call it whatever) without an outlook. When you call it a day, just spare a couple of moments to ruminate on how was the day, had you experienced something good, be it a wish from someone. Had this wish bubble be kept springy, the world will ever require a day dedicated for world peace.

Static file content not served by IIS

Recently on encountering a issue where in the images / CSS / js and others being rendered with status as 200 (OK). But when looked in the browser, the content was not displayed. The static modules were enabled in windows features along with the MIME type mapping. Finally, when checking in the IIS Server, it was found that the Static module was missing in the handler registration. Updating that fixed the issue.

Could not load library when hosting the app in IIS

When an application is deployed in the server and if it throws the could not load library exception, we can enable the x86 support in application pool. In case any assembly was built targeting the x86 platform, this would be the right fix to make the site available. However, it is strongly advised not to target specific platform unless a firm reason be found.

How to debug OWIN related stuff using Symbol Source

I ran into a situation today wherein I was required to debug the Google Authentication middleware built on top of OWIN. I already had the code checked out from Katana project in CodePlex. However, when I tried to use, it was the latest bits [dev channel]. My app was using the version 2.1 and the dev version was in 3.0. Tired of searching the tag for the version 2.1, I came to know that the symbols for the various open source projects are made available from SymbolSource.org Given this piece of information, I read the steps on how to configure the symbol server in Visual studio and then upon successful source registration, I was able to step through the middlewares and do the debugging stuff. Things that I did were, Grab the public [authentication less uri access] from Symbol Source [ http://srv.symbolsource.org/pdb/Public] Go to Tools -> Options -> Debugger -> General. Uncheck “Enable Just My Code (Managed only)”. Uncheck “Enable .NET Framework source stepping”.

Push code from local machine to github in windows

To   Create a new Repository in Github from the gitbash command line interface, follow the steps below, touch README.md git init git add README.md git commit -m "first commit" git remote add origin https://github.com/saravanandorai/GitURL.git git push -u origin master To   push existing code to a Repository in Github from the gitbash command line interface, follow the steps below git remote add origin https://github.com/saravanandorai/GitURL.git git push -u origin master Additional Reference: See here

Difference between the pfx and cer / cert

May be this post is kind of well known to many. I have encountered this couple of days back, while working with a custom authorization server. Hence posted here. There are two types of digital certificate, 1. .pfx, an archive kind of certificate which contains a public key, private key and other public keys like the CA(certifying authority) public keys. 2. .cer, which contains only the public keys. Pfx certificates are meant to be only on the server, whereas the car or cert files are meant to be shared with the client's that will talk to the server. In authorization server, the server uses pfx files and the clients use the .cer or the .cert files.

Debugging application running in IIS Express

In order to debug the application that is run in IIS Express in visual studio, following are the steps 1. Run the application /s in IIS express configured in visual studio 2. In the system tray or task bar near by the system clock, IIS express icon will be shown. Click on it and click on "show all application" 3. All the application hosted in IIS express will be shown along with the corresponding process ids. 4. In visual studio, go to Tools > Attach to process > in the processes, order by the process I'd and choose the correct process I'd to debug the application. 5. If the process is not listed there, pick on the "show process from all user account" check box in the bottom left corner of the window. 6. Leave a break point in the source and that's it. Hope this helps.

Internals of Active Directory Federation Services [ADFS]

The following is an image that illustrates the working internals of Active Directory Federation Services [ADFS]. This image was created out of reading lengthy text contents from various web pages.