Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to grant sendmail permission to sql server user?

I have a database user which is the owner of the database. The application requirement is to send mail using database mail of sql server .

Is there any way that I can add grant only send mail permission to that user?

I have a user named testuser having server roles public and is db_owner for 1 database. Please tell me the way that I don`t need to give sysadmin serverroles to that user.

like image 317
Nitesh Kumar Avatar asked Jul 26 '12 09:07

Nitesh Kumar


People also ask

How do I grant permission to SQL user?

To grant permissions for the user, switch to the Object Permissions tab. In the Objects block, select the database object on which you want to grant privileges. In the Available Privileges block, select the permissions to be assigned and click Save.

How do I grant a drop permission in SQL Server?

You cannot assign DROP or CREATE permissions on a single table, as those are schema and database level permissions: DROP TABLE requires ALTER permission on the schema to which the table belongs, CONTROL permission on the table, or membership in the db_ddladmin fixed database role.


1 Answers

Please try with the below 2 options.

USE msdb;
--add our user
CREATE USER  ClarkKent FOR LOGIN  ClarkKent; 
--give this user rights to use dbmail
exec sp_addrolemember 'DatabaseMailUserRole', 'ClarkKent'

now if we know ClarkKent is getting his authorization from a windows group, then you add that windows group as a user, and add that group to the same role;

USE msdb;
--add our user via a group we know he is in 
CREATE USER 'mydomain\BusinessGroup' FOR LOGIN   'mydomain\BusinessGroup'; 
--give this GROUP rights to use dbmail
exec sp_addrolemember 'DatabaseMailUserRole', 'mydomain\BusinessGroup'
like image 107
shiva Avatar answered Sep 20 '22 19:09

shiva