I am working on a C#.net 2008 desktop application where code has been added to verify if a user has access to various parts of a desktop application based upon the tab they select. The C#.net 2008 desktop, code has been added to verify if a user has access to various parts of the application. The user will only see the parts of the desktop they should have access to or a error message will be displayed right away saying 'you do not have access, contact network administrator'.
There has been code added to sql server 2008 r2 also that checks to see if the user has access based upon the groups they are assigned to in sql server.
Current problem. When the user tries to access the sql server r2 database through the application, a runtime error is displayed shwoing the user does not have access (basically to sql server).
Thus to display a user friendly message and close out of the applicartion, I would likec to know what my options are.
Thus let me know if I can do any of the following:
1. Is there some code the .net desktop can access before the first call to sql server to see if the user has access based upon how sql server accesses the ldap code? If so, can you tell me and/or point me to a reference I can use to include in my code?
2. Is there some code the .net desktop can access before all calsl to sql server to see if the user has access based upon how sql server accesses the ldap code? If so, can you tell me and/or point me to a reference I can use to include in my code?
3. If there is no .net code to check prior to the call, what kind of logic can I put in a try catch block to capture the error? What kind of an error would I be getting that I need to check for? What is the exception type, error code, error code number, and/or error message that I should be checking for? Would you display come sample code and/or point me to a url that I can use as a reference?
Loading
Andrew FensterPosted Sep 1, 2011, 4:19 PM
Really, however, it seems like you're going about it all wrong. You need to have ONE test of the user's authority. That test can be whether the user has access to the database, or it could be which groups (if any) the user has been assigned to. What you are proposing doing is having TWO tests: can the user access the database, and if so, which groups has he been assigned to.
What I suggest is that you set up a database connection string, complete with user ID and password, and use this to access the database to check on the user's authority. That way, even if you have an unauthorized user, you can still access the database. Once you're in the database, you can see whether the user has been assigned to a group. Once you have checked on the user's authority, you can go back to using LDAP.