Solved

How to Allow users who are using a specific Application to modify database

Posted on 2013-12-28
4
124 Views
Last Modified: 2014-07-08
hello
 we have sql server database "MyCompanyDB" "sql server 2012,Windows 2008R2"
there is a desktop Application and a website , both connected to this database "MyCompanyDB"
what i need is to prevent any Data modification "Update/Delete/add" UNLESS the end user use these Applications ... for example if a developer or user use a third party application that connect the database he cant modify the data even from management studio
how can i implement that
Note: we are using SQL Server Authentication as the server authentication
0
Comment
Question by:ali_alannah
4 Comments
 
LVL 9

Expert Comment

by:QuinnDex
ID: 39743423
this will deny access to any database unless the user is sysadmin or DB owner, you can then create read only logins dbowner for those you want to read db and read/write dbowner for application and website

USE MASTER
GO
DENY VIEW ANY DATABASE TO PUBLIC
GO

Open in new window

0
 
LVL 22

Expert Comment

by:Patrick Bogers
ID: 39743446
Hi

The application/website could login with a account that is dbowner for that database where you can give users a seperate readonly login (public) that is tied to this particulair database.
0
 
LVL 15

Assisted Solution

by:Aaron Shilo
Aaron Shilo earned 150 total points
ID: 39746848
hi

you should use a DDL trigger on the database.

read up : DDL TRIGGER
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 350 total points
ID: 39747009
Have the application set a specific APP_NAME when it makes its connection to SQL Server.

Then add DML triggers on the table that reject any mods unless the APP_NAME matches what you specified in the valid application.

For example:


CREATE TRIGGER table1_trigger_verify_app
ON dbo.table1
AFTER DELETE, INSERT, UPDATE
AS
SET NOCOUNT ON
--if app name shows it's from good app, exit from trigger, which processes mods normally
IF APP_NAME() = 'Your_good_application_name_Bb78-E5D2a10597BB'
    RETURN
--missing or invalid app name, so rollback any/all mods user tried to make
RAISERROR('You cannot make any modifications to these tables outside the main application.', 16, 1)
ROLLBACK TRANSACTION
GO
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question