Solved

Application Permissions

Posted on 2010-08-31
10
477 Views
Last Modified: 2013-12-17
I have a C# Windows application written to access tables and stored procedures in SQL Server  database. The table permissions (Select, Insert, Update, and Delete) and stored procedure (Execute) permissions for the user when accessing the database through the C# application.

However, if the user accesses the same table another way (like Microsoft Access), the permission for the table is Select only.

I was thinking that I need to accomplish this by setting up:
1) Application Role (in SQL Server) for the C# application table (Select, Insert, Update, and Delete) and stored procedure (Execute) permissions.
2) Database Role for the other ways to access the tables with Select only permissions.

Is setting up Application Role and Database Role accurate? If yes, my C# application uses many datasets throughout the application, how do I use sp_setapprole for the whole application? If no, what are the suggestions?
0
Comment
Question by:LenTompkins
  • 6
  • 4
10 Comments
 
LVL 16

Expert Comment

by:vdr1620
ID: 33570793
if you are doing for the 1st time then i would suggest using a Wizard instead of executing the proc..here are the steps

In the database -->security --> Roles --> application role ---> new application role --> create a user and password --select the role needed ---> in securables ---Click on search --> specify objects --> Ok ---> object Types --> select the object types and click ok and then using the browse button you can select the stored procedures,tables etc that you want to..

check these links
http://articles.techrepublic.com.com/5100-10878_11-5068954.html
http://www.sqlteam.com/article/using-application-roles

0
 

Author Comment

by:LenTompkins
ID: 33570887
Thanks for the reply, but my question is should I be setting up the Application and Database Roles to do what I need (see above) or can I do it some other way in the database?
0
 
LVL 16

Expert Comment

by:vdr1620
ID: 33571062
No,You will need to set up Roles accordingly
0
 

Author Comment

by:LenTompkins
ID: 33571178
I know how to setup the roles in the database, but I am not sure how to use the application role through the whole C# Windows application without keep executing sp_setapprole for each time I open a database connection and how do I do it for datasets since I don't need to open the database connection?
0
 
LVL 16

Expert Comment

by:vdr1620
ID: 33571317
i am not good with C#..but her's my thought

you do not need to execute the proc every time..once you set up a role with user id and password..Any one who logins with those credentials will have the privileges..i believe you will need to establish a Connection using these credentials
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:LenTompkins
ID: 33571993
When you say "Any one who loggins with those credentials" do you mean trying to connect using the credentials of the Application Role or the user?
0
 
LVL 16

Accepted Solution

by:
vdr1620 earned 500 total points
ID: 33577534
yeah, i meant any one trying to connect using the credentials will have those privileges
0
 

Author Comment

by:LenTompkins
ID: 33581672
Through the Windows application, I will try logging in as the user and see if the privileges of the Application Role take effect.
0
 

Author Comment

by:LenTompkins
ID: 33591608
Resolution: Instead of setting up the Application and Database Role, we created a new UserID/Password in the Database Security/Logins with sysadmin privileges and changed the C# application's connection string: removing the Integrated Security=True and setting UserID/Password to the new one created.
0
 

Author Closing Comment

by:LenTompkins
ID: 33591633
Even though we setup the Application Roles, it did not fix the problem, but we do appreciate the assistance.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now