문제

I'm having a similar issue to this question (https://dba.stackexchange.com/posts/123094/edit)! I have followed the following article: https://azure.microsoft.com/en-gb/documentation/articles/sql-database-manage-logins/ and just cannot get it to fully work.

-- first, connect to the master database

CREATE LOGIN login1 WITH password='password';

-- Establish a new connection to the database

CREATE USER login1user FROM LOGIN login1;

GRANT CONNECT TO login1user

EXEC sp_addrolemember 'db_datareader', 'login1user ';

EXEC sp_addrolemember 'db_datawriter', 'login1user ';

EXEC sp_addrolemember 'db_ddladmin', 'login1user ';

The issue is, I cannot connect to my database with login1user. I have to use the login1 details, which isn't really what I was expecting to happen. I would be happy having the names the same, except for bullet point three in the remarks section of this article (https://msdn.microsoft.com/library/ff929188.aspx), suggests that this isn't best practise.

Any help appreciated!

도움이 되었습니까?

해결책

It looks like you mixed a few different steps from the Azure article. Many of these Azure articles contain lots of great information but the layout is borderline horrible. Topics just blend into each other making it confusing for most readers (DB firewall configuration is another commonly confused doc).

If you want to use contained DBs with contained users, your create user statement should be something like

CREATE USER MyContainedUser01 WITH password='MyL@m3P@$$0rd';

as described in https://azure.microsoft.com/en-gb/documentation/articles/sql-database-manage-logins/#managing-contained-database-users

When you create a user mapped to a login as per your sample script, that's a regular, non-contained user. With that, you need to connect using the login which then maps to the user.

다른 팁

Login to Azure SQL using contained user through Object Explorer of SQL Server Management Studio gives 'Login failure', unless we specify the contained database in the Connection Properties (Options / Connection Properties in login window).

Initial Catalog={contained-db-name};

Login through web app is fine.

enter image description here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top