Wednesday 3 June 2015

To find locked tables in sql server 2008


Using below query you can find locked tables in sql server 2008


select
    object_name(p.object_id) as TableName,
    resource_type, resource_description
from
    sys.dm_tran_locks l
    join sys.partitions p on l.resource_associated_entity_id = p.hobt_id

Google+ Authentication in MVC application Or google+ external login in MVC application


After lot of investigation, I found one good solution for google Authentication in mvc application.

If your application is not working on google+ login, using below code you can find solution for the problem.

OAuthWebSecurity.RegisterGoogleClient();

Simple Steps to achieve google + login in mvc application.
Step 1: Install GoogleOAuth2 Using Package Manager Console. Below you can find the command

Install-Package DotNetOpenAuth.GoogleOAuth2


Step 2: Add following code in RegisterAuth() method.
   GoogleOAuth2Client googleClient=new GoogleOAuth2Client("Your-ClientId", "Your-ClientSecret");

   OAuthWebSecurity.RegisterClient(googleClient, "Google", new Dictionary<string, object>());

This will allows you to authenticate google.


Step 3: In ExternalLoginCallback method has to call
GoogleOAuth2Client.RewriteRequest(); method to get the result, before calling the “VerifyAuthentication” method.


AuthenticationResult result = OAuthWebSecurity.VerifyAuthentication(Url.Action("ExternalLoginCallback", new { ReturnUrl = returnUrl }));


Hope this will help you... :)

Your feedback and suggestions are always welcomed.