Link to home
Start Free TrialLog in
Avatar of lagneskog
lagneskog

asked on

vb.net, control if user has right to stored procedure on SQL Server

Before calling a stored procedure I would like to check if the user has rights to it. I use Integrated security and SQL Server 2000, Windows 2003 Server. Or maybe there is a better way to avoid failure in the application if the user has not right to run this SP.


Thanks in advance.
Avatar of rdrunner
rdrunner

Why not just execute it and handle the exception?

If you check if the user has the rights you would have to querry the DB 2 times to get the job done. One time in order to check if he is allowed and once in order to get the work done. This is one wasted trip in case you succeed.

If you just try to execute it and handle the exception properly then you have not wasted a trip to the sql server since you accomplish both questions with one action. An exception is not allwas an evil thing to generate. See it as some information service also. There are places where you can efficently work with errors and i think this is a valid scenario for this :)
Avatar of lagneskog

ASKER

Thanks rdrunnder

Could you please provide a smal snippet of vb.net code as you thought it would look like.
ASKER CERTIFIED SOLUTION
Avatar of rdrunner
rdrunner

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial