在 sql azure 中创建新用户/登录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6058058/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 10:38:13  来源:igfitidea点击:

Creating new user/login in sql azure

sqlazure-sql-database

提问by kapil

Create a new user/login in sql azure with access to read/insert/update on the database items like tables sp,view etc.

在 sql azure 中创建一个新用户/登录,可以访问对表 sp、view 等数据库项目的读取/插入/更新。

This user will not have the permission to drop table/drop procedures.

该用户将没有删除表/删除过程的权限。

Please give me an example.

请给我一个例子。

回答by Frank Boucher

You can also user the Azure User Management console - AUMC to manage the Logins and Users.

您还可以使用 Azure 用户管理控制台 - AUMC 来管理登录名和用户。

It's a open source project available on codeplex AUMC.codeplex.com

这是一个可在 codeplex AUMC.codeplex.com 上获得的开源项目

Project Description

Azure User Management Console - AUMC is a User Graphic Interface (GUI) that manages the users and logins of an Azure SQL database. The tool is simply converting your action into T-SQL commands and execute them on the Azure SQL Database.

项目描述

Azure 用户管理控制台 - AUMC 是一个用户图形界面 (GUI),用于管理 Azure SQL 数据库的用户和登录。该工具只是将您的操作转换为 T-SQL 命令并在 Azure SQL 数据库上执行它们。

A quick simple tool with a user interface!

一个带有用户界面的快速简单的工具!

Enjoy!

享受!

回答by David Sopko

First connect to the server and switch to the master database. In master create a login and then add a user for that login to the master database.

首先连接服务器,切换到master数据库。在 master 中创建一个登录名,然后为该登录名添加一个用户到 master 数据库。

CREATE LOGIN [MyLogin] WITH password='xxxxxxxxx'
GO

CREATE USER [MyUser] FOR LOGIN [MyLogin] WITH DEFAULT_SCHEMA=[dbo] 
GO

Next connect/switch to the database you want the new user for. Create a user in that database

接下来连接/切换到您希望新用户使用的数据库。在该数据库中创建一个用户

CREATE USER [MyUser] FOR LOGIN [MyLogin] WITH DEFAULT_SCHEMA=[dbo]
GO


EXEC sp_addrolemember 'db_datareader', 'MyUser';
GO

EXEC sp_addrolemember 'db_datawriter', 'MyUser';
GO

GRANT EXECUTE ON SCHEMA :: dbo TO MyUser;
GO

回答by Herve Roggero

please read this article from Microsoft on how to properly create logins, users and assigning access rights in SQL Azure: Managing Databases and Logins

请阅读 Microsoft 的这篇关于如何在 SQL Azure 中正确创建登录名、用户和分配访问权限的文章:管理数据库和登录名

Then, in order to assign or deny specific permissions, review this article from Microsoft as well: Granting Access to a Database Object

然后,为了分配或拒绝特定权限,还请查看 Microsoft 的这篇文章:授予对数据库对象的访问权限

And here is the link to specifically deny access to permissions: Deny Object Permissions

这是专门拒绝访问权限的链接:拒绝对象权限

Note that you can also apply permissions to schemas. A schema is a container of database objects on which you can assign permissions. So you could easily place all your stored procedures in a single schema that you created to that effect, deny alter/drop permission, and grant execute on the schema directly. This way, all the objects within that schema will inherit the permissions defined. Here is the article for schema permissions: GRANT Schema Permission

请注意,您还可以将权限应用于架构。架构是您可以为其分配权限的数据库对象的容器。因此,您可以轻松地将所有存储过程放置在您为此创建的单个架构中,拒绝更改/删除权限,并直接在架构上授予执行权限。这样,该架构中的所有对象都将继承定义的权限。这是架构权限的文章:GRANT Schema Permission

回答by Shaman

Also you can do it manually by assigning proper user roles. Check out article: How to create custom user login for Azure SQL Database

您也可以通过分配适当的用户角色来手动完成。查看文章:如何为 Azure SQL 数据库创建自定义用户登录