I had the need this week to check an SQL account password on a user which was configured in a way the account couldn’t access the server via the SQL Manager. The account password was lost years ago. I cracked the account password from the executable from legacy application. The code below is Visual Basic 2015 .net console app, and was written so I could log directly into the database in order to verify the password.
The modern methods of connecting to a db via ADO.net, which use Data Grid views, Data Sets, Binding Sources, and Table Adapters controls, the old school way of doing things is still relevant.
Anyway, Here’s the code:
Option Explicit On
Option Strict On
Dim conn As String = “Data Source=<SERVER FQDN>;Initial Catalog=<Database Name>;UID=<USER>;PWD=<Password>”
Dim queryString As String = ”
Using connection As New SqlConnection(conn)
Dim command As New SqlCommand(queryString, connection)
Catch ex As Exception