Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL-Server-2008
Hi
I'm building an application using C# windows form and SQLExpress2008
As for the security I decided to set some application roles.
I read few articles about what they are and how they work but honestly didn't get a thing!
As I realized the application role is active as long as the application is connected via an open sqlconnection. So the moment the connection which executes sp_setapprole is closed the role itself seems to be lost. At this point granted permissions are revoked and it throws an unhandled sql exception saying "Select permission is denied".
Do I have to simply let the connection be after I've executed sp_seapprole procedure? Can any one please get me out of the dark please!
Posted 29-Dec-12 21:04pm
SedMhd270
Comments
Abhishek Pant at 30-Dec-12 3:43am
   
just use login based admin roles.if username is this then admin form opens and if other then other
SedMhd at 30-Dec-12 6:11am
   
thanks for your quick replay.
The thing is that the database revokes the user's permission as it's supposed to but it won't grant the application role's permissions. I personally think it makes sense! I close the connection by invoking Close() method of the connection after executing sp_setapproll. So the database has no chance to recognize the application on further connections. So how can keep the database aware of the application when I'm establishing another connection to the database?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CPallini 375
1 Sergey Alexandrovich Kryukov 370
2 BillWoodruff 314
3 George Jonsson 279
4 OriginalGriff 257
0 OriginalGriff 5,030
1 CPallini 4,115
2 Sergey Alexandrovich Kryukov 3,554
3 George Jonsson 2,826
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 30 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100