Read only queries Using ADO.NET
I want to limit the application to read only queries. In other words, I want the application to process only those queries which are not changing the state of the database. I am using ADO.NET. I do not want to create a new user against the database with read only permissions. Any suggestions are welcome.
c# sql sql-server ado.net
add a comment |
I want to limit the application to read only queries. In other words, I want the application to process only those queries which are not changing the state of the database. I am using ADO.NET. I do not want to create a new user against the database with read only permissions. Any suggestions are welcome.
c# sql sql-server ado.net
Why don't you want to create a new user? That's the real way to do this, unless you have 100% control of the application code and can ensure that no data altering statements are executed through it.
– squillman
Jan 18 at 19:04
The best, most secure, easiest way to do that is to limit the database user the application is using to readonly. There's even a built in role calleddb_denydatawriter
which will automatically deny writing privileges for any database object from the user that has it.
– Zohar Peled
Jan 20 at 10:13
The database is an external db and it does not allow to create a new database user (We don't have privileges to create a new database user). I am using Windows Authentication.
– Programmer
Jan 21 at 7:05
add a comment |
I want to limit the application to read only queries. In other words, I want the application to process only those queries which are not changing the state of the database. I am using ADO.NET. I do not want to create a new user against the database with read only permissions. Any suggestions are welcome.
c# sql sql-server ado.net
I want to limit the application to read only queries. In other words, I want the application to process only those queries which are not changing the state of the database. I am using ADO.NET. I do not want to create a new user against the database with read only permissions. Any suggestions are welcome.
c# sql sql-server ado.net
c# sql sql-server ado.net
edited Jan 18 at 19:08
marc_s
574k12811091256
574k12811091256
asked Jan 18 at 18:57
ProgrammerProgrammer
197
197
Why don't you want to create a new user? That's the real way to do this, unless you have 100% control of the application code and can ensure that no data altering statements are executed through it.
– squillman
Jan 18 at 19:04
The best, most secure, easiest way to do that is to limit the database user the application is using to readonly. There's even a built in role calleddb_denydatawriter
which will automatically deny writing privileges for any database object from the user that has it.
– Zohar Peled
Jan 20 at 10:13
The database is an external db and it does not allow to create a new database user (We don't have privileges to create a new database user). I am using Windows Authentication.
– Programmer
Jan 21 at 7:05
add a comment |
Why don't you want to create a new user? That's the real way to do this, unless you have 100% control of the application code and can ensure that no data altering statements are executed through it.
– squillman
Jan 18 at 19:04
The best, most secure, easiest way to do that is to limit the database user the application is using to readonly. There's even a built in role calleddb_denydatawriter
which will automatically deny writing privileges for any database object from the user that has it.
– Zohar Peled
Jan 20 at 10:13
The database is an external db and it does not allow to create a new database user (We don't have privileges to create a new database user). I am using Windows Authentication.
– Programmer
Jan 21 at 7:05
Why don't you want to create a new user? That's the real way to do this, unless you have 100% control of the application code and can ensure that no data altering statements are executed through it.
– squillman
Jan 18 at 19:04
Why don't you want to create a new user? That's the real way to do this, unless you have 100% control of the application code and can ensure that no data altering statements are executed through it.
– squillman
Jan 18 at 19:04
The best, most secure, easiest way to do that is to limit the database user the application is using to readonly. There's even a built in role called
db_denydatawriter
which will automatically deny writing privileges for any database object from the user that has it.– Zohar Peled
Jan 20 at 10:13
The best, most secure, easiest way to do that is to limit the database user the application is using to readonly. There's even a built in role called
db_denydatawriter
which will automatically deny writing privileges for any database object from the user that has it.– Zohar Peled
Jan 20 at 10:13
The database is an external db and it does not allow to create a new database user (We don't have privileges to create a new database user). I am using Windows Authentication.
– Programmer
Jan 21 at 7:05
The database is an external db and it does not allow to create a new database user (We don't have privileges to create a new database user). I am using Windows Authentication.
– Programmer
Jan 21 at 7:05
add a comment |
2 Answers
2
active
oldest
votes
Option 1: SQL Authentication
You can use connections as shown below:
Server ={serverName}; Initial Catalog = {DB_Name}; User Id={uid}; Password={pwd};
Use the uid which has only read access in database.
Option 2: Windows Authentication
If you want to use Integrated Security = True; (i.e. windows authentication) then you will have to grant readonly access to the windows user (under which the program runs).
Hope this helps.
Thanks for the reply. Application is using Windows Authentication and is running under the scope of an administrator (which is a Windows User). Administrator has all the privileges and we cannot change the permissions level. What if, the database even don't allow us to create a new database user with read only rights. Any thoughts?
– Programmer
Jan 21 at 7:11
add a comment |
You can create triggers to cancel any insert update or delete through a trigger at the database level. The trigger would end with a rollback to cancel the transaction. You would have to figure out who kicked off the trigger so other users can update the db.
I would not do it - I would take away any permission (except select) from the account being used for the application. I have created many, many triggers but I have never heard anyone using database triggers to enforce read only.
Application is using Windows Authentication and is running under the scope of an administrator. So, it has all the priveleges and can execute all the queries. The database is an external db and it doesn't allow us to create a new database user with read only permissions. Any thoughts on doing this without creating a new db user, changing the permission level of the existing Windows user.
– Programmer
Jan 21 at 7:33
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54259947%2fread-only-queries-using-ado-net%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Option 1: SQL Authentication
You can use connections as shown below:
Server ={serverName}; Initial Catalog = {DB_Name}; User Id={uid}; Password={pwd};
Use the uid which has only read access in database.
Option 2: Windows Authentication
If you want to use Integrated Security = True; (i.e. windows authentication) then you will have to grant readonly access to the windows user (under which the program runs).
Hope this helps.
Thanks for the reply. Application is using Windows Authentication and is running under the scope of an administrator (which is a Windows User). Administrator has all the privileges and we cannot change the permissions level. What if, the database even don't allow us to create a new database user with read only rights. Any thoughts?
– Programmer
Jan 21 at 7:11
add a comment |
Option 1: SQL Authentication
You can use connections as shown below:
Server ={serverName}; Initial Catalog = {DB_Name}; User Id={uid}; Password={pwd};
Use the uid which has only read access in database.
Option 2: Windows Authentication
If you want to use Integrated Security = True; (i.e. windows authentication) then you will have to grant readonly access to the windows user (under which the program runs).
Hope this helps.
Thanks for the reply. Application is using Windows Authentication and is running under the scope of an administrator (which is a Windows User). Administrator has all the privileges and we cannot change the permissions level. What if, the database even don't allow us to create a new database user with read only rights. Any thoughts?
– Programmer
Jan 21 at 7:11
add a comment |
Option 1: SQL Authentication
You can use connections as shown below:
Server ={serverName}; Initial Catalog = {DB_Name}; User Id={uid}; Password={pwd};
Use the uid which has only read access in database.
Option 2: Windows Authentication
If you want to use Integrated Security = True; (i.e. windows authentication) then you will have to grant readonly access to the windows user (under which the program runs).
Hope this helps.
Option 1: SQL Authentication
You can use connections as shown below:
Server ={serverName}; Initial Catalog = {DB_Name}; User Id={uid}; Password={pwd};
Use the uid which has only read access in database.
Option 2: Windows Authentication
If you want to use Integrated Security = True; (i.e. windows authentication) then you will have to grant readonly access to the windows user (under which the program runs).
Hope this helps.
answered Jan 18 at 19:04
Manoj ChoudhariManoj Choudhari
1,096115
1,096115
Thanks for the reply. Application is using Windows Authentication and is running under the scope of an administrator (which is a Windows User). Administrator has all the privileges and we cannot change the permissions level. What if, the database even don't allow us to create a new database user with read only rights. Any thoughts?
– Programmer
Jan 21 at 7:11
add a comment |
Thanks for the reply. Application is using Windows Authentication and is running under the scope of an administrator (which is a Windows User). Administrator has all the privileges and we cannot change the permissions level. What if, the database even don't allow us to create a new database user with read only rights. Any thoughts?
– Programmer
Jan 21 at 7:11
Thanks for the reply. Application is using Windows Authentication and is running under the scope of an administrator (which is a Windows User). Administrator has all the privileges and we cannot change the permissions level. What if, the database even don't allow us to create a new database user with read only rights. Any thoughts?
– Programmer
Jan 21 at 7:11
Thanks for the reply. Application is using Windows Authentication and is running under the scope of an administrator (which is a Windows User). Administrator has all the privileges and we cannot change the permissions level. What if, the database even don't allow us to create a new database user with read only rights. Any thoughts?
– Programmer
Jan 21 at 7:11
add a comment |
You can create triggers to cancel any insert update or delete through a trigger at the database level. The trigger would end with a rollback to cancel the transaction. You would have to figure out who kicked off the trigger so other users can update the db.
I would not do it - I would take away any permission (except select) from the account being used for the application. I have created many, many triggers but I have never heard anyone using database triggers to enforce read only.
Application is using Windows Authentication and is running under the scope of an administrator. So, it has all the priveleges and can execute all the queries. The database is an external db and it doesn't allow us to create a new database user with read only permissions. Any thoughts on doing this without creating a new db user, changing the permission level of the existing Windows user.
– Programmer
Jan 21 at 7:33
add a comment |
You can create triggers to cancel any insert update or delete through a trigger at the database level. The trigger would end with a rollback to cancel the transaction. You would have to figure out who kicked off the trigger so other users can update the db.
I would not do it - I would take away any permission (except select) from the account being used for the application. I have created many, many triggers but I have never heard anyone using database triggers to enforce read only.
Application is using Windows Authentication and is running under the scope of an administrator. So, it has all the priveleges and can execute all the queries. The database is an external db and it doesn't allow us to create a new database user with read only permissions. Any thoughts on doing this without creating a new db user, changing the permission level of the existing Windows user.
– Programmer
Jan 21 at 7:33
add a comment |
You can create triggers to cancel any insert update or delete through a trigger at the database level. The trigger would end with a rollback to cancel the transaction. You would have to figure out who kicked off the trigger so other users can update the db.
I would not do it - I would take away any permission (except select) from the account being used for the application. I have created many, many triggers but I have never heard anyone using database triggers to enforce read only.
You can create triggers to cancel any insert update or delete through a trigger at the database level. The trigger would end with a rollback to cancel the transaction. You would have to figure out who kicked off the trigger so other users can update the db.
I would not do it - I would take away any permission (except select) from the account being used for the application. I have created many, many triggers but I have never heard anyone using database triggers to enforce read only.
edited Jan 18 at 19:14
answered Jan 18 at 19:08
benjamin moskovitsbenjamin moskovits
3,7011516
3,7011516
Application is using Windows Authentication and is running under the scope of an administrator. So, it has all the priveleges and can execute all the queries. The database is an external db and it doesn't allow us to create a new database user with read only permissions. Any thoughts on doing this without creating a new db user, changing the permission level of the existing Windows user.
– Programmer
Jan 21 at 7:33
add a comment |
Application is using Windows Authentication and is running under the scope of an administrator. So, it has all the priveleges and can execute all the queries. The database is an external db and it doesn't allow us to create a new database user with read only permissions. Any thoughts on doing this without creating a new db user, changing the permission level of the existing Windows user.
– Programmer
Jan 21 at 7:33
Application is using Windows Authentication and is running under the scope of an administrator. So, it has all the priveleges and can execute all the queries. The database is an external db and it doesn't allow us to create a new database user with read only permissions. Any thoughts on doing this without creating a new db user, changing the permission level of the existing Windows user.
– Programmer
Jan 21 at 7:33
Application is using Windows Authentication and is running under the scope of an administrator. So, it has all the priveleges and can execute all the queries. The database is an external db and it doesn't allow us to create a new database user with read only permissions. Any thoughts on doing this without creating a new db user, changing the permission level of the existing Windows user.
– Programmer
Jan 21 at 7:33
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54259947%2fread-only-queries-using-ado-net%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why don't you want to create a new user? That's the real way to do this, unless you have 100% control of the application code and can ensure that no data altering statements are executed through it.
– squillman
Jan 18 at 19:04
The best, most secure, easiest way to do that is to limit the database user the application is using to readonly. There's even a built in role called
db_denydatawriter
which will automatically deny writing privileges for any database object from the user that has it.– Zohar Peled
Jan 20 at 10:13
The database is an external db and it does not allow to create a new database user (We don't have privileges to create a new database user). I am using Windows Authentication.
– Programmer
Jan 21 at 7:05