Managing users
You can add and remove users, as well as manage their individual settings.
Getting a list of users
- Go to the folder page and select Managed Service for SQL Server.
- Click on the name of the cluster you need and then select the Users tab.
Use the list API method: pass the ID of the required cluster in the clusterId
request parameter.
To find out the cluster ID, get a list of clusters in the folder.
Adding a user
- Go to the folder page and select Managed Service for SQL Server.
- Click on the name of the cluster you need and select the tab Users.
- Click Add.
- Enter a database username and password (from 8 to 128 characters).
- Select one or more databases that the user should have access to:
- Click Add database.
- Select the database from the drop-down list.
- Repeat the previous two steps until all the required databases are selected.
- To delete a database that was added by mistake, click to the right of the database name.
- Set up user roles for each of the selected databases.
- Click Create.
Use the create API method and pass the following in the request:
- ID of the cluster where you want to create a user, in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - Username, in the
userSpec.name
parameter. - User password, in the
userSpec.password
parameter. - One or more databases that the user must have access to, in one or more
userSpec.permissions.databaseName
parameters. - User roles for each of the selected databases, in one or more
userSpec.permissions.roles
parameters.
Changing a password
To change the user's password:
- Go to the folder page and select Managed Service for SQL Server.
- Click on the name of the cluster you need and select the tab Users.
- Click and select Change password.
- Set a new password and click Edit.
Use the update API method and pass the following in the request:
- In the
clusterId
parameter, the ID of the cluster where the user is located. To find out the cluster ID, get a list of clusters in the folder. - Username, in the
userName
parameter. To find out the username, get a list of users in the cluster. - New user password, in the
password
parameter. - List of user configuration fields to be changed (in this case, the
password
), in theupdateMask
parameter.
Warning
This API method resets any settings that aren't passed explicitly in the request to their defaults.
To avoid this, be sure to pass the name of the user password field: password
, in the updateMask
parameter.
Changing user settings
To change the user settings:
- Go to the folder page and select Managed Service for SQL Server.
- Click on the name of the cluster you need and select the tab Users.
- Click and select Configure.
- Set up user permissions to access certain databases:
- To grant access to the required databases:
- Click Add database.
- Select the database from the drop-down list.
- Repeat the previous two steps until all the required databases are selected.
- To revoke access to a specific database, remove it from the list by clicking to the right of the database name.
- To grant access to the required databases:
- Set up user roles for each of the selected databases.
- Click Save.
Use the update API method and pass the following in the request:
- In the
clusterId
parameter, the ID of the cluster where the user is located. To find out the cluster ID, get a list of clusters in the folder. - Username, in the
userName
parameter. To find out the username, get a list of users in the cluster. - New values for user settings.
- List of user configuration fields to be changed, in the
updateMask
parameter.
Warning
This API method resets any settings that aren't passed explicitly in the request to their defaults.
To avoid this, in the updateMask
parameter, list the settings you want to change (in a single line, separated by commas).
Deleting a user
- Go to the folder page and select Managed Service for SQL Server.
- Click on the name of the cluster you need and select the tab Users.
- Click and select Delete.
- Confirm user deletion.
Use the delete API method and pass the following in the request:
- In the
clusterId
parameter, the ID of the cluster where the user is located. To find out the cluster ID, get a list of clusters in the folder. - Username, in the
userName
parameter. To find out the username, get a list of users in the cluster.
Examples
Add a user with read-only permissions
To add a new user user2
to an existing cluster with read-only access to the db1
database:
-
Create a user with the name
user2
. Select the databases that the user should have access to. -
Connect to the
db1
database under the account of the database owner. -
To only grant access rights to the
Products
table, in the defaultdbo
schema, run the command:GRANT SELECT ON dbo.Products TO user2; GO
-
To grant access permissions to all the
myschema
schema tables, run the command:GRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::myschema TO user2; GO
To revoke the granted privileges, run the commands:
REVOKE SELECT ON dbo.Products FROM user2;
REVOKE SELECT, INSERT, UPDATE, DELETE ON SCHEMA::myschema FROM user2;
GO