简体   繁体   English

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

[英]Creating new user/login in sql azure

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.请给我一个例子。

First connect to the server and switch to the master database.首先连接服务器,切换到master数据库。 In master create a login and then add a user for that login to the master database.在 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

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. Azure 用户管理控制台 - AUMC 是一个用户图形界面 (GUI),用于管理 Azure SQL 数据库的用户和登录。 The tool is simply converting your action into T-SQL commands and execute them on the Azure SQL Database.该工具只是将您的操作转换为 T-SQL 命令并在 Azure SQL 数据库上执行它们。

A quick simple tool with a user interface!一个带有用户界面的快速简单的工具!

Enjoy!享受!

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

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 数据库创建自定义用户登录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM