Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server Management Studio 2012 - Deploy Database to SQL Azure - SQL71501 User has an unresolved reference to Login

While trying to do anything related to deploying to Azure/creating a BACPAC in SSMS 2012 I encounter error for each of 3 users in my database (who are not the user that is currently logged on)

Validation of the schema model for data package failed. Error SQL71501: Error validating element [VARIABLE_USER_NAME_HERE]: User: [VARIABLE_USER_NAME_HERE] has an unresolved reference to Login [VARIABLE_USER_NAME_HERE]. (Microsoft.SqlServer.Dac)

Any clues?

like image 668
Caius Jard Avatar asked Jun 17 '14 10:06

Caius Jard


1 Answers

This SO question really helped: Can I ignore logins when publishing a Visual Studio Database project?

I realised that the user I was logged on (to my local database) with, had no permissions to view the login details for the login associated with the peer users that were being complained about in the error message. Written in more plain English, and assuming that there are just 2 database users (mr_spoon and mr_fork), what the error message means is "The currently logged on user [mr_spoon] can see that there is another user called "mr_fork" but cannot view the details of the login [also called "mr_fork" in this case] associated with that user"

Logging onto the master DB with my Windows admin login, and then running this query solved it:

GRANT VIEW DEFINITION ON LOGIN::the_login_name_in_the_error_message TO the_user_i_logged_on_with_and_ran_the_export_from

i.e. admin should run this:
GRANT VIEW DEFINITION ON LOGIN::mr_fork TO mr_spoon

Note that SQL Server permission system supports the notion of both Users and Logins, so I've hopefully been quite careful to say user when I mean user and login where I mean login. Why not just run the export from the admin login you may ask? The machine that can do that doesn't have SSMS2012 nor is it possible to install it, and it's the only machine the admin login works from.. Thus, I'd expect this problem is rare but maybe one day this will help someone

I thought I'd post a Q&A because everywhere I looked I only found reference to SQL71501 within the context of SSDT, not SSMS2012/Azure Deployment

like image 153
Caius Jard Avatar answered Sep 23 '22 13:09

Caius Jard