Is there any way to determine why is a Login is losing a User mapping?

I've created them with the following SQL ...

CREATE LOGIN [qauser] WITH PASSWORD = 'xxxx', DEFAULT_DATABASE = [app_tst],  
                           CHECK_EXPIRATION=OFF, CHECK_POLICY = OFF

CREATE USER [qauser] FOR LOGIN [qauser] WITH DEFAULT_SCHEMA = [devdba]

and then successfully used the matching login on a linked server with synonyms to tables in the original.

Some time later, the synonyms fail and checking the LOGIN properties, the User Mapping have gone for the database / user. I have to re-run the CREATE LOGIN / USER script to get them to work ... but using the main devdba login, the synonyms continues to work

What could be causing this loss ?

migrated from stackoverflow.com Jun 17 '12 at 23:54

This question came from our site for professional and enthusiast programmers.

  • Are you restoring [app_tst] sometimes by any chance? – user5147 Jun 15 '12 at 10:12
  • @Josien Not that I'm aware of, but it's not my server, and it's a "test" server, so you may well be right ... I'll check. – SteveC Jun 15 '12 at 11:08
  • 1
    Have you seen that article? sqlservercentral.com/Forums/Topic870948-1292-1.aspx#bm872678 – David Brabant Jun 15 '12 at 13:54
  • @DavidBrabant Nope, but I have now ... thanks for the pointer ... SPOT ON, there is a restore every morning from a copy of the live db. You should put this in as an answer, so I can vote it – SteveC Jun 15 '12 at 14:01

From the post here (user mapping disappearing):

"The only time I have seen something like this happen, was when the application DBAs where restoring test scenario DB backups over the existing databases, without telling us SQL Server SysAdmins what they were doing. This would of course wipe out all of our later user mappings to those databases. So, you might want to check for something like that... "

And in the same thread, a pointer to a script for knowing when the database was last restored.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.