RE: Error in SQL Enterprise Manager after migrating a user & their WS

From: Rebecca Chen [MSFT] (v-rebc_at_online.microsoft.com)
Date: 09/15/04


Date: Wed, 15 Sep 2004 08:04:11 GMT

Hi Joe,

Actually, it is a SQL Server related issue. Please post SQL Server related
issue to the following newsgroup: Microsoft.public.sqlserver

According to my experience, this is an expected behavior. This SQL Server
register information is stored in the Registry key;

HKCU\Software\Microsoft\Microsoft SQL Server\80\Tools\SQLEW\Registered
Servers X

IF the users have not altered their configuration to store it on a remote
server, the restoration of these Registry Keys is not something we support,
however I was able to provide a VB Script for your reference:

Servers X

An application can be written using SQL-DMO's RegisteredServers object to
automate the process of collecting this information for each Enterprise
Manager user so that when something like a domain change occurs, the
application can then re-register the SQL Server instances.

The RegisteredServer object exposes the attributes of a single,
registry-listed instance of Microsoft SQL Server. Once this information is
collected for by the user running the application, they could run the
application again to register these servers at a later time.

Here is a sample VB Script using the RegisteredServers Collection in
SQL-DMO:

NOTE: Script is not supported in this newsgroup. I only provide the code
for your reference.

Also, in this sample application, the application retrieves the username
and password if the registration is done using SQL Authentication, it
stores values to a table in text (readable format) and could potentially
cause security issues.

Here are the steps:

1. Create a vbs file and call it readreg.vbs which contains the following.
Please substitute <servername> with SQL Server name and <password> with the
SA password.

It also creates a table RegServers in pubs database so make sure that this
does not exist. This script collects information about the currently
registered servers and stores the information in the RegServers table.

' turn on this to trap any syntax or declaration errors Option Explicit

' beginning of routine
Dim oApplication
Dim oServerGroups
Dim oServerGroup
Dim oRegisteredServer
Dim oNewRegisteredServer
Dim oSQLServer
Dim MsgOutput

set oSQLServer = CreateObject("SQLDMO.SQLServer")
Set oApplication = CreateObject("SQLDMO.Application")
Set oServerGroups = oApplication.ServerGroups
 
oSQLServer.Connect "<servername>", "sa", "<password>"
oSQLServer.ExecuteImmediate

"Create table pubs..RegServers(ServerName varchar(30), SLogin varchar(30),
SPassword varchar(30), IsNtAuth varchar(2))"

For Each oServerGroup in oApplication.ServerGroups
 For Each oRegisteredServer in oServerGroup.RegisteredServers
        MsgOutput = "Insert Into Pubs..RegServers values("
        MsgOutput = MsgOutput + "'" + oRegisteredServer.Name + "', '" +
oRegisteredServer.Login + "', '" + oRegisteredServer.Password + "', '" +
CStr(oRegisteredServer.UseTrustedConnection) + "')"
        oSQLServer.ExecuteImmediate MsgOutput
    Next
Next

oSQLServer.Disconnect

2. To run, open a command-prompt and run "cscript readreg.vbs".

3. To verify that the information was retrieved correctly, go to the SQL
Server
specified in the script and run the following:

use pubs
select * from RegServers

4. Create another vbs file and call it createreg.vbs which contains the
following:

Again substitute <servername> with SQL Server name and <password> with the
sa
password.

' turn on this to trap any syntax or declaration errors
Option Explicit

' beginning of routine
Dim oApplication
Dim oServerGroups
Dim oServerGroup
Dim oRegisteredServer
Dim oNewRegisteredServer
Dim oSQLServer
Dim MsgOutput

set oSQLServer = CreateObject("SQLDMO.SQLServer")
Set oApplication = CreateObject("SQLDMO.Application")
Set oServerGroups = oApplication.ServerGroups
 
oSQLServer.Connect "<servername>", "sa", "<password>"
oSQLServer.ExecuteImmediate

"Create table pubs..RegServers(ServerName varchar(30), SLogin varchar(30),
SPassword varchar(30), IsNtAuth varchar(2))"

For Each oServerGroup in oApplication.ServerGroups
    For Each oRegisteredServer in oServerGroup.RegisteredServers
        MsgOutput = "Insert Into Pubs..RegServers values("
        MsgOutput = MsgOutput + "'" + oRegisteredServer.Name + "', '" +
oRegisteredServer.Login + "', '" + oRegisteredServer.Password + "', '" +
CStr(oRegisteredServer.UseTrustedConnection) + "')"
oSQLServer.ExecuteImmediate MsgOutput
Next
Next

oSQLServer.Disconnect

2. To run, open a command-prompt and run "cscript readreg.vbs".

3. To verify that the information was retrieved correctly, go to the SQL
Server
specified in the script and run the following:

use pubs
select * from RegServers

4. Create another vbs file and call it createreg.vbs which contains the
following:

Again substitute <servername> with SQL Server name and <password> with the
sa
password.

' turn on this to trap any syntax or declaration errors
Option Explicit

' beginning of routine
Dim oApplication
Dim oServerGroups
Dim oServerGroup
Dim oRegisteredServer
Dim oNewRegisteredServer
Dim oSQLServer
Dim oQueryResults
Dim MsgOutput
Dim num
Dim SrvNameOutput
Dim LoginOutput
Dim PassOutput
Dim AuthOutput
Dim GetLoginOutput

set oSQLServer = CreateObject("SQLDMO.SQLServer")
Set oApplication = CreateObject("SQLDMO.Application")
Set oServerGroups = oApplication.ServerGroups oSQLServer.Connect
"<servername>",
"sa", "<password>"

set oQueryResults = oSQLServer.ExecuteWithResults ("Select ServerName,
SLogin,
SPassword, IsNtAuth from pubs..RegServers") For num = 1 To
oQueryResults.Rows
            SrvNameOutput = oQueryResults.GetColumnString(num, 1)
            LoginOutput = oQueryResults.GetColumnString(num, 2)
            PassOutput = oQueryResults.GetColumnString(num, 3)
            AuthOutput = oQueryResults.GetColumnString(num, 4)

            If LoginOutput = "" Then LoginOutput = " "
            Set oNewRegisteredServer = CreateObject("SQLDMO.RegisteredServer")
            oNewRegisteredServer.Login = LoginOutput
            oNewRegisteredServer.Name = SrvNameOutput
            oNewRegisteredServer.Password = PassOutput
            oNewRegisteredServer.UseTrustedConnection = CLng(AuthOutput)
            oServerGroups("SQL Server
Group").RegisteredServers.Add(oNewRegisteredServer)
Next

oSQLServer.Disconnect

5. To run, open a command-prompt and run "cscript createreg.vbs".

NOTE:
a. When doing the tests, please make sure that Enterprise Manager is
closed.
b. The script gathers information about the registered servers for the
currently

logged on user.
c. If you want to test on a single machine, you may do the following:
- run readreg.vbs
- Delete the registration from Enterprise Manager or delete the entries in
the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL
Server\80\Tools\SQLEW\Registered

Servers X

Please be warned that modifying the registry can cause serious damage to
the computer and may even cause a reinstallation of the operating system.
- run createreg.vbs - open Enterprise Manager and check the registration

Further questions, please post it to SQL server newsgroup.

Have a great day!

Best regards,

Rebecca Chen

MCSE2000 MCDBA CCNA

Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

=====================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



Relevant Pages

  • Re: SQLCeConnection
    ... can ping the main server that holds the SQL Server Enterprise as will ... Dim myConnection As Data.SqlClient.SqlConnection ... SQL Mobile database that came from SQL Server, ... SQlCeConnection and when I actually need to use the SQlceConnection? ...
    (microsoft.public.sqlserver.ce)
  • Re: connect vb app to sql 2005 express
    ... Dim dbCommand As New SqlCommand ... Dim FirstColValues As ArrayList = New ArrayList ... I restarted the SQL server service after this ...
    (microsoft.public.dotnet.languages.vb)
  • Re: connect vb app to sql 2005 express
    ... I got the basic query to work. ... Dim dbCommand As New SqlCommand ... I restarted the SQL server service after this ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Rpchttp_setup.vbs
    ... Dim oArg, oRootDSE, oADOconn, oADOcomm, rs, oOutputFile, oFSO ... Const ADS_SCOPE_ONELEVEL = 1 ... Unable to create registry import file '%x'. ... Const L_STATEXSKV_TEXT = "Skipped %x Exchange servers without Windows Server ...
    (microsoft.public.exchange.admin)
  • Re: rpchttp_setup.vbs script
    ... Dim oArg, oRootDSE, oADOconn, oADOcomm, rs, oOutputFile, oFSO ... Const ADS_SCOPE_ONELEVEL = 1 ... Unable to create registry import file '%x'. ... Const L_STATEXSKV_TEXT = "Skipped %x Exchange servers without Windows Server ...
    (microsoft.public.exchange.admin)

Quantcast