Map login to users

  • what you did do should have worked. just tested and it worked find on my machine.

    you can check the associated user and logins to see if the goodusername user is mapped to the correct login.

    select a.name as loginname ,a.sid as loginsid,b.name as username,b.sid as usersid

    from sys.server_principals a

    inner join sys.database_principals b

    on a.sid = b.sid

    where b.name = 'GoodUserName'

    or a.name = 'GoodUserName';

    Bob
    -----------------------------------------------------------------------------
    How to post to get the best help[/url]

  • I would suggest to script out all users (and logins) with their permissions. You can find many script to do that on the internet and on this forum (http://www.sqlservercentral.com/search/?q=permissions&t=s&sort=relevance). Use a find/replace to change all the "badusername"'s to "goodusername"'s in the generated script. Run the script and remove all logins/users with "badusername"'s.

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
  • I found this script useful:

    http://weblogs.sqlteam.com/billg/archive/2010/07/08/Scripting-out-SQL-Server-Logins.aspx

    I'm not sure if it will solve your exact problem in its given form, but I suggest that you review it for ideas. And of course as others have said, there are many similar scripts out there.

    Good luck.

    - webrunner

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

  • HanShi (3/10/2014)


    I would suggest to script out all users (and logins) with their permissions. You can find many script to do that on the internet and on this forum (http://www.sqlservercentral.com/search/?q=permissions&t=s&sort=relevance). Use a find/replace to change all the "badusername"'s to "goodusername"'s in the generated script. Run the script and remove all logins/users with "badusername"'s.

    I would prefer this method. Either you can drop badusername users or remap them to the goodusername logins.

    --

    SQLBuddy

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

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