Showing posts with label ratherthan. Show all posts
Showing posts with label ratherthan. Show all posts

Friday, February 24, 2012

Change SQL Server Authentication Programmatically

Hi,

Does anyone here know whether it is possible to change the
authentication method of a SQL server instance programmatically, rather
than going through enterprise manager.

I am using SQL-DMO (under C#) for some other things, but the
documentation is so bad that I can't find out whether what I want to do
can be done. I have also tried googling but came up empty handed.

I hope that someone can help me.

Cheers
JonoHi

At a guess try SetSecurityMode under the SQLServer/IntegratedSecurity Object

John
"Jono Price" <jonathan_daivd_price@.hotmail.com> wrote in message
news:4298443f$0$542$ed2619ec@.ptn-nntp-reader03.plus.net...
> Hi,
> Does anyone here know whether it is possible to change the authentication
> method of a SQL server instance programmatically, rather than going
> through enterprise manager.
> I am using SQL-DMO (under C#) for some other things, but the documentation
> is so bad that I can't find out whether what I want to do can be done. I
> have also tried googling but came up empty handed.
> I hope that someone can help me.
> Cheers
> Jono|||John Bell wrote:
> Hi
> At a guess try SetSecurityMode under the SQLServer/IntegratedSecurity Object
> John

Thank you so much. I couldn't believe that it wasn't possible, but I
also couldn't find that.

Thanks again.

Jono

Change SQL Server Authentication method programmatically

Hi,
Does anyone here know whether it is possible to change the
authentication method of a SQL server instance programmatically, rather
than going through enterprise manager.
I am using SQL-DMO (under C#) for some other things, but the
documentation is so bad that I can't find out whether what I want to do
can be done. I have also tried googling but came up empty handed.
I hope that someone can help me.
Cheers
JonoThe only thing I know about, though I am not quite familar with SQL-DMO is
to change the regkey:, using the XP xp_regwrite
For registry changing try this regkey:
Default instance:
" HKEY_LOCAL_MACHINE\Software\M_icrosoft\M
SSqlserver\MSSqlServ_er\LoginMode"
to 2 for mixed-mode or 1 for integrated.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Jono Price" <jonathan_daivd_price@.hotmail.com> schrieb im Newsbeitrag
news:42984478$0$542$ed2619ec@.ptn-nntp-reader03.plus.net...
> Hi,
> Does anyone here know whether it is possible to change the authentication
> method of a SQL server instance programmatically, rather than going
> through enterprise manager.
> I am using SQL-DMO (under C#) for some other things, but the documentation
> is so bad that I can't find out whether what I want to do can be done. I
> have also tried googling but came up empty handed.
> I hope that someone can help me.
> Cheers
> Jono|||"Jono Price" schrieb:
> Hi,
> Does anyone here know whether it is possible to change the
> authentication method of a SQL server instance programmatically, rather
> than going through enterprise manager.
> I am using SQL-DMO (under C#) for some other things, but the
> documentation is so bad that I can't find out whether what I want to do
> can be done. I have also tried googling but came up empty handed.
> I hope that someone can help me.
> Cheers
> Jono
This is a VB solution (with SQLDMO). You'll have to translate this to C#
yourself.
On Error GoTo ErrSec
Dim srv As SQLDMO.SQLServer2
Set srv = New SQLDMO.SQLServer2
' integrated security login
srv.LoginSecure = True
' or standard security login
srv.LoginSecure = False
srv.Login = "sa"
srv.Password = "MyPassword"
srv.Connect "MyServer"
' switch to integrated
srv.IntegratedSecurity.SecurityMode = SQLDMOSecurity_Integrated
' or switch to mixed mode
srv.IntegratedSecurity.SecurityMode = SQLDMOSecurity_Mixed
' restart server: shutdown looses the connection and generates an error.
' we catch that error in the error section and restart the server.
srv.Shutdown
Exit Function
ErrSec:
srv.Disconnect
srv.Start (True) ' true reconnects automatically|||See SQLServer->ServerLoginMode()
_7s6h.asp" target="_blank">http://msdn.microsoft.com/library/d...r />
_7s6h.asp
GertD@.SQLDev.Net
Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
Copyright SQLDev.Net 1991-2005 All rights reserved.
"Jono Price" <jonathan_daivd_price@.hotmail.com> wrote in message
news:42984478$0$542$ed2619ec@.ptn-nntp-reader03.plus.net...
> Hi,
> Does anyone here know whether it is possible to change the authentication
> method of a SQL server instance programmatically, rather than going
> through enterprise manager.
> I am using SQL-DMO (under C#) for some other things, but the documentation
> is so bad that I can't find out whether what I want to do can be done. I
> have also tried googling but came up empty handed.
> I hope that someone can help me.
> Cheers
> Jono