11/23/2006

Change Authentication Mode with Registry

Hi,
What if we need to change / read / write some registry entry in Server but we donot have access to server!!!! but at the same time we do have SA/Admin privilege on SQL Server (Assuming we need to change registry settings on SQL Server itself ) for example while setting up SQL Server they have installed SQL Server with *Mixed Authentication Mode* and now we need to change it to *Windows Only Authentication Mode* to do so from Query Analyzer we do have xTended Store Procedure to help us they are xp_regread and xp_regwrite
For an instance assume that your Authentication Mode is set to *Mixed Authentication Mode* to read it run below query in QA if it shows ‘0’ or '2' means that authentication mode is Mixed

EXECUTE master..xp_regread
'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer',
'LoginMode'

Now if we wants to change it to *Windows Only* run below query in QA

declare @md int

set @md=1

EXECUTE master..xp_regwrite

'HKEY_LOCAL_MACHINE',

'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer',

'LoginMode', 'reg_dword', @md

This will make changes in your Registry and change your *Authentication Mode* also.

Disclaimer : In the example above both the xTended Stored Procedure used are Undocumented so use it at your own risk and please check for its availability / support before using it.


This posting is provided * AS IS * for the shake of knowledge sharing only.

0 comments:

Post a Comment

I appreciate your time, thanks for posting your comment. I will review and reply to your comment as soon as I can.

Thank you
Hemantgiri