Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 User Mappings lost

Author  Topic 

WrecknRoll
Starting Member

9 Posts

Posted - 2011-10-07 : 13:39:19
(I am running SQL Server 2005 SP2 Developer on Windows XP)

One of the things I have to be able to do is programatically save (Backup) or restore (Refresh) some of my SQL Databases. The easiest/simplest way to do this is to stop my SQL Server then copy my .mdf and .ldf files either from the active folder to the backup or vice-versa.

This has worked perfectly in the past, never had any problems. Now however a strange thing is happening. I stop SQL Server then copy my active files to a backup folder (so the active files remain completely unchanged, just copied only). Then I restart SQL Server.

After doing this my User Mappings for the databases are gone. The users within each specific database have become orphaned.

Why is it losing these mappings after simply stopping, copying then restarting?

Any help y'all could offer would be much appreciated! Thanks...

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-10-08 : 05:48:32
Google for 'orphaned users'. Tonnes of info on reasons and fix.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

paultech
Yak Posting Veteran

79 Posts

Posted - 2011-10-09 : 07:19:49
hi,

Orphaning can happen if the database user is mapped to a SID that is not present in the new server instance.

each user in for a database had an SID in the master database , so when you deattach the database in any way , this SID is deleted from the master so when attaching again , it cannot find it and its login .

see the following link for more details:

http://www.mssqltips.com/sqlservertip/1590/understanding-and-dealing-with-orphaned-users-in-a-sql-server-database/

Go to Top of Page
   

- Advertisement -