Click here to Skip to main content
11,495,534 members (64,371 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# SQL-Server-2008
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 22:04pm
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 Dnyaneshwar@Pune 692
1 CHill60 318
2 Sascha Lefèvre 265
3 Nakul Chaudhari 236
4 Sergey Alexandrovich Kryukov 230
0 Sergey Alexandrovich Kryukov 10,322
1 OriginalGriff 8,821
2 Sascha Lefèvre 3,889
3 Maciej Los 3,422
4 Richard Deeming 2,560

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 30 Dec 2012
Copyright © CodeProject, 1999-2015
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