Re: Automate syncing login ids of master db at remote server
- From: "astrally2005" <andrewdritchie@xxxxxxxxxxxx>
- Date: 17 Mar 2006 05:40:14 -0800
I have continued to search the web for a solution and have found some
scripts provided by Umachandar Jayachandran at
http://www.sqlmag.com/Article/ArticleID/25710/sql_server_25710.html,
which seem to work, in that the logins ids are located within
sysxlogins table within the master db on the standby server, however
these logins are not visible under users within Enterprise Manager,
does this matter?
CREATE PROCEDURE sp_Syncronize_Logins_from_prod AS
set ANSI_NULLS OFF
set ANSI_WARNINGS OFF
DECLARE @logins cursor
DECLARE @name sysname, @password sysname,
@dbname sysname, @language sysname,
@sid binary(16), @isntuser bit
SET @logins = cursor fast_forward FOR
SELECT l.loginname, l.password, l.dbname, l.language, l.sid,
l.isntuser
FROM [server\instance].master.dbo.syslogins AS l
WHERE l.loginname IS NOT NULL
OPEN @logins
WHILE(1=1)
BEGIN
FETCH @logins INTO @name, @password, @dbname,
@language, @sid, @isntuser
IF @@fetch_status < 0 break
IF is_srvrolemember( 'sysadmin', @name ) IS NOT NULL
CONTINUE
IF @isntuser = 0
EXEC sp_addlogin @name, @password, @dbname,
@language, @sid, 'skip_encryption'
ELSE
BEGIN
EXEC sp_grantlogin @name
EXEC sp_defaultdb @name, @dbname
EXEC sp_defaultlanguage @name, @language
END
END
DEALLOCATE @logins
.
- References:
- Automate syncing login ids of master db at remote server
- From: astrally2005
- Re: Automate syncing login ids of master db at remote server
- From: Michael Hotek
- Re: Automate syncing login ids of master db at remote server
- From: astrally2005
- Automate syncing login ids of master db at remote server
- Prev by Date: Re: Replication problem.. Please help..
- Next by Date: Re: Transaction and commands question
- Previous by thread: Re: Automate syncing login ids of master db at remote server
- Next by thread: Upgrading publishers to 2005 (4 questions) sorry i know this isn't a consulting fourm.
- Index(es):
Relevant Pages
|