Grant admin rights to user temporarily

S

scuba79

I have a secured database using a mdw file that was created with the
database. I have some code that will be run under one of the user accounts.
That account does not have any rights to the tables. I need to be able to
give them rights to the tables just as long as the code is running. Here is
the code that I'm currently using.


While Not rst.EOF
Set con = db.Containers("Tables")
Set doc = con.Documents(rst("Name"))
doc.UserName = "pdlead"
doc.Permissions = dbSecFullAccess
con.Documents.Refresh
rst.MoveNext
Wend

ImportLoc = GetFileName

this runs without any problems, however, when I click on another button. I
get an error message stating that the user does not have permissions to
"work" with the tables.

Any assistance is greatly appreciated
 
G

Graham Wideman [Visio MVP]

scuba:

One of the points of not giving a user rights is to also not give them
rights to give themself rights... When you say:
"I need to be able to give them rights"

.... you are not logged on when they are running your code... they are.
Consequently the code, acting with the permissions of your user, can't give
your user more rights.

You don't say what the code does that needs these special rights, but it's
possible you could solve your problem with the help of a "run with owner
permissions" (RWOP) query -- that's a query that you enable to run with the
permissions of a user that has more permissions, regardless of who the
actual user is who runs it.

From Help topic "Change a query's permissions":

"you can assign others permission to view the data your query returns or, in
the case of an action query, to run the query, even if they are otherwise
restricted from viewing the query's underlying table or query. "

Hope that helps,

Graham
 
S

scuba79

I look into that.

The issue is that I have a database with empty tables, as it should, when I
give it to the end user, they will have to import the data from another
database into this one.

Since this importing of records is only a one time thing, I need to give
that user the ability to delete the empty tables and then create new ones
with the existing data from the other database.

Hope this makes sense..
 
S

scuba79

Graham,

Thanks alot... "run with owner permissions" (RWOP) query was the solution
that I needed...

Again thank you

Scuba79
 

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

Top