SID Mapping

  • OK I've been plowing through all the scripts but am running short of time.

    Can someone recommend a script that will run through all of my user databases and map the SID of the logins?

    Thanks so much,

    Jerry

  • Something like this

    exec sp_msforeachdb @command1 =

    N'select ''?'' as [database],u.[name],u.sid,l.[name] as [login]

    from ?.dbo.sysusers u

    inner join master.dbo.syslogins l

    on l.sid = u.sid

    where u.issqluser = 1'

    Far away is close at hand in the images of elsewhere.
    Anon.

  • David,

    Thanks for the reply but I guess I wasn't clear on what I needed. Hence the 'in a hurry' .

    I'm doing disaster recovery / staging server for testing and I am updating the server from a production server. On restore I lose the SIDs.

    So I'm needing a good script that updates the SIDs along the lines for Microsoft's SIDMapper.exe. Though I guess I could add that as a command in sp_msforeachdb.

    Regardless thanks for enlightening me to this sp. Obviously a very useful tool

    Jerry

  • Are you needing to get the SIDs as they change from the OS or make sure that the database users match up to the SIDs already in master? If that's the case, you can run a cursor to retrieve each username and then execute an sp_change_users_login to get the SIDs back in synch.

    K. Brian Kelley
    @kbriankelley

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply