How to determine the current user's rights

  • Thread starter Thread starter Bob Trabucco
  • Start date Start date
B

Bob Trabucco

Hi all,

My .NET application needs to know if the currently logged on user has rights
enough to create global tables, indexes, stored procedures, views, etc in
the current database.

The program runs through routines that create all these tables and we have
to make sure there is sufficient permission to create these items for all
users of the database to use.

Is there any defined stored procedures or views that returns that kind of
system information?

Thanks you!

Bob Trabucco
Coastal Computer Corporation
 
It is database dependent, for SQL Server see the PERMISSIONS entry in SQL
Server BOL

e.g.
This example determines whether the current user can execute the CREATE
TABLE statement.

IF PERMISSIONS()&2=2
CREATE TABLE test_table (col1 INT)
ELSE
PRINT 'ERROR: The current user cannot create a table.'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top