Consider a particular scenario where sa account gets disabled (by any reason) and windows authentication doesn’t have the rights to connect to the database server; basically windows authentication is not available. In such a case, you will not be able to do much from Sql server management studio to enable sa account again because to do that, you will have to run a query and to run the query, you need to be connected first to the Database. **Deadlock** So what to do?
There is a pretty simple hack for this. You need to edit a particular registry key property’s value. Follow the below steps to enable mixed mode authentication when you’re locked out. However, please note that this could be a potential security risk (note the word ‘hack’ mentioned earlier). Make sure your sa account has a very strong password.
- Open Run (Windows + r) and type regedit. Hit enter. Click OK.
- This opens the Registry editor. Navigate to the registry key
HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\MSSQLServer\LoginMode
Note: For those who don’t know what HKLM is, HKLM refers to HKEY_LOCAL_MACHINE
—-The text highlighted above in red can change based on what instance name you’re using.
- Change the value of LoginMode to 0x00000002 (2). The value 2 refers to Mixed Mode authentication and value 0x00000001 (1) refers to Windows Authentication. Make sure it is now set to 0x00000002.
- Restart the SQL Server and pc (if required). Now you will be able to connect to the database using sa account.
Hope this helps!
Posted in .NET, SQL Server
Tagged enable sa account, enable sa without connecting to SSMS, sa account disabled, sa account disabled by mistake, sa account locked out, sa disabled, sql server, sql server sa account disabled, sql server sa account locked, ssms enable sa without query
I recently setup an ADFS website on a server and required the site to display the forms authentication page asking for log in credentials whenever the AD was accessed. But every time, I ended up getting the windows authentication pop up instead of the pop up.
After doing some research online, I found that ADFS website always tries to use Windows authentication before trying to use the forms authentication. If forms authentication is used, the log in page is shown.
To make the Forms authentication log in page show up instead of the pop up, follow the below steps:
- Open the physical path of the adfs/ls site. You can do this from IIS manager. Expand the site –> Right-click –> Explore.
- Open the web.config file and locate the <localAuthenticationTypes> tag. This section lists the order in which authentication takes place.
- Comment out all the items except Forms authentication. Alternatively, you can move the “Forms” key to the first of the list. This will make the site to use Forms authentication before Windows authentication.
- Save the web.config file. Try opening the site and the login page should show up as expected.
Hope this helps!
Posted in .NET, General, IIS
Tagged ADFS, adfs 2.0 sign in pages customization, adfs forms authentication, adfs forms authentication login page, adfs login page customization, authentication, enable forms authentication in adfs website, forms authentication login page in adfs website, Show ADFS login page instead of windows authentication pop up, show forms authentication page in ADFS authentication
There are many instances where you have to provide a custom account identity to an App pool in IIS. There are also instances where you might have forgotten the password for that account which has to be set as identity for that Application Pool. In such cases, you can use the APPCMD command to retrieve the password for that user. One thing to remember is that there has to be an app pool existing in the machine already which has been assigned that account’s Identity for us to retrieve it’s password. Please note: This can be used for IIS 7 and above.
appcmd is an IIS tool used to manage IIS server. It provides many functions that can be used to manager server related activities like create/configure sites, start/recycle/stop app pools, etc.
Retrieve Password of an App Pool identity account:
- To retrieve password for an app pool identity account, open the command prompt in administrative mode.
- Navigate to C:\System\Windows32\inetsrv directory. This is the location where appcmd.exe exists.
- Type the below command and press enter.
appcmd.exe list apppool <<app_pool_name>> /text:*
For example: I have an app pool in my IIS named SampleAppPool which has been assigned a particular account’s identity whose password I would like to retrieve. So I would enter the below command in command prompt.
Press enter and the result will be as shown below. Due to security reasons, I have removed the username and password from the image but trust me, it shows the username and password there.Hope this helps!
I had to install Windows Identity Foundation SDK in a Windows 2012 R2 server for setting up Claims-based authentication. So I downloaded the SDK and started the installation. Immediately I was shown this error popup.
The cause of the error is apparent – Windows Identity Foundation (WIF, going forward) is not installed in my server.
To install WIF runtime, follow the below steps if you’re using Windows Server 2012
- Open server manager. Click on Add Roles & features.
- Click Next and navigate till the Features section. If you want to know how to navigate through “Add Roles and Features” dialog box, refer to my post here. Make sure you come back to this post once you reach Features section.
- Scroll down and you will find “Windows Identity Foundation”. Select that and click next.
Note: In your case, it will be unchecked and not disabled and available for selection unlike the one shown here in the screen shot below.
- Click next and finish the installation.
This will install WIF Runtime in your server. After this is completed, run the SDK setup file again. This time, WIF SDK will get installed without any issues.
To install WIF Runtime on Windows 8, 8.1:
- In start menu, type “Turn Windows Features On and Off”. Open the dialog box.
- Scroll down and enable Windows Identity Foundation.
- Click OK.
This install WIF Runtime in Windows 8, 8.1.
Hope this helps!
Posted in .NET, General
Tagged How to install WIF Runtime, How to install Windows Identity Foundation Runtime, How to install Windows Identity Foundation Runtime in Windows Server 2012, install Windows Identity Foundation, install Windows Identity Foundation runtime, installing WIF runtime, Installing Windows Identity Foundation Runtime. Resolving Windows Identity Foundation SDK Installation error., The Windows Identity Foundation Runtime must be installed for the Windows Identity Foundation SDK installation to continue, WIF Runtime, WIF SDK installation error, Windows Identity Foundation, Windows Identity Foundation SDK installation error, Windows Server 2012
Firstly, I would like to thank you for visiting my blog and encouraging me to write more posts. However, I’ve been very busy lately and have not been able to post much from the past few months.
So now, with the new year starting tomorrow, I would like to take a resolution that I would write a new post regularly here (at least 2 posts per month) and make this blog more useful and also improve my knowledge further.
I have also taken a resolution to improve my skills on Azure primarily and also on development of Windows universal apps. I will work hard to achieve these by the mid of this year. I’m yet to plan for the next half of the year ;-) During the course of the first 6 months, I will make it a point to post all my learning here in an easy-to-understand way so that it can help others who are also looking to learn the same.
Duh! Enough of boring talk. Coming to the actual point, I would like to wholeheartedly wish you all a very very happy new year! :-) Hope you all have a great year ahead with lots of wonderful moments!
Looking forward to making 2015 wonderful! Cheers!
The WordPress.com stats helper monkeys prepared a 2014 annual report for this blog.
Here’s an excerpt:
The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 23,000 times in 2014. If it were a concert at Sydney Opera House, it would take about 9 sold-out performances for that many people to see it.
Click here to see the complete report.