Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have a database called 'foo' on the first sql server instance called 'SQL01' that is backed up nightly via a snapshot with Snap Manager for SQL Server and then flex cloned and restored to a second server instance called 'SQL02'. In the database foo there is a sql user called 'someuser' that has datareader and stored procedure privileges.

After the restore operation I cannot access the foo database on SQL02 with the someuser user. I can see that the permissions appear to be set correctly for the user, but can't access the database. The error is "The server principal "someuser" is not able to access the database "foo" under the current security context."

If I remove the user from the database and then add them again it works fine. Any ideas?

share|improve this question

4 Answers 4

up vote 0 down vote accepted

sp_change_users_login is old way of doing things and since you are using SQL Server 2005, try using ALTER USER syntax.

http://sqlblog.com/blogs/greg_low/archive/2009/02/02/much-ado-about-logins-and-sids.aspx

http://msdn.microsoft.com/en-us/library/ms176060.aspx

share|improve this answer
    
Looks like I weighed in on that sqlblog thread. :) –  Ben Thul May 26 '11 at 11:57

Check out sp_change_users_login Do a sp_change_users_login 'report', if there are results, use sp_change_users_login 'autofis','someuser'

share|improve this answer

you will probably find you need to delete the user out of the database you have restored, then open the user under server security and set its permissions into that DB again

share|improve this answer

The server logins are stored in the master database and are not moved with the application DBs. You can create the login at the server level and then use sp_change_users_login 'auto_fix','loginname' as suggested by Sankar. To move a larger set of logins, check this link: How to transfer logins and passwords between instances of SQL Server

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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