Temporary login

C

Carol Giannini

Is it possible, for the purposes of one function that requires administrative
permissions, to reset the current user to Admin, execute the function, and
then require the user to log in again?

Many thanks in advance -- I don't post much but read a lot and the help on
this forum is phenomenal.
 
R

Rick Brandt

Carol said:
Is it possible, for the purposes of one function that requires
administrative permissions, to reset the current user to Admin,
execute the function, and then require the user to log in again?

Many thanks in advance -- I don't post much but read a lot and the
help on this forum is phenomenal.

Not exactly, but you can open a new Workspace object and then within that
Workspace you can open another Database object using a different user's
credentials.

Dim ws As Workspace

Set ws = CreateWorkspace("MyWorkspace", "UserName", "Password")
ws.OpenDatabase "path to file"
....

You could prompt for the password so that only a user who knew it could run the
function, but you would not have to "log back in" to revert back to the original
user. Once the workspace object went out of focus at the end of the fucntion
all activities would revert back to the original user.
 
C

Carol Giannini

I can't get this to work. I'm not a programmer, so hopefully it's something
I'm doing that's just dumb and simple to fix, but even after reading all the
posts and everything I can find in Access Help, I can't figure out what it
is. Here's my code:

* * * * *

Dim wrkspc As Workspace
Dim db As Database

' Create new Workspace object dbTemp, user Adminuser, password Ker22mit
' (user and password exist in security settings as a member of the Admins
group
' with full permissions)
Set wrkspc = CreateWorkspace("dbTemp", "adminuser", "Ker22mit")

With wrkspc
Set db = wrkspc.OpenDatabase("C:\FCM-C\FCM.mdb")
[Do function]
End with

* * * * *

This code runs with no errors until it gets to the function. If I'm
originally logged on as a regular user without the necessary permissions, it
returns a "you don't have the right permissions" error. It's as though I'm
still in the default workspace as originally logged in. What am I missing?

_____________________________
 
R

Rick Brandt

Carol said:
I can't get this to work. I'm not a programmer, so hopefully it's
something I'm doing that's just dumb and simple to fix, but even
after reading all the posts and everything I can find in Access Help,
I can't figure out what it is. Here's my code:

* * * * *

Dim wrkspc As Workspace
Dim db As Database

' Create new Workspace object dbTemp, user Adminuser, password
Ker22mit ' (user and password exist in security settings as a member
of the Admins group
' with full permissions)
Set wrkspc = CreateWorkspace("dbTemp", "adminuser", "Ker22mit")

With wrkspc
Set db = wrkspc.OpenDatabase("C:\FCM-C\FCM.mdb")
[Do function]
End with

* * * * *

This code runs with no errors until it gets to the function. If I'm
originally logged on as a regular user without the necessary
permissions, it returns a "you don't have the right permissions"
error. It's as though I'm still in the default workspace as
originally logged in. What am I missing?

_____________________________

Rick Brandt said:
Not exactly, but you can open a new Workspace object and then
within that Workspace you can open another Database object using a
different user's credentials.

Dim ws As Workspace

Set ws = CreateWorkspace("MyWorkspace", "UserName", "Password")
ws.OpenDatabase "path to file"
....

You could prompt for the password so that only a user who knew it
could run the function, but you would not have to "log back in" to
revert back to the original user. Once the workspace object went
out of focus at the end of the fucntion all activities would revert
back to the original user.
 
C

Carol Giannini

Rick: There's a reply from you but nothing in it. Would you resend? Thx.

Rick Brandt said:
Carol said:
I can't get this to work. I'm not a programmer, so hopefully it's
something I'm doing that's just dumb and simple to fix, but even
after reading all the posts and everything I can find in Access Help,
I can't figure out what it is. Here's my code:

* * * * *

Dim wrkspc As Workspace
Dim db As Database

' Create new Workspace object dbTemp, user Adminuser, password
Ker22mit ' (user and password exist in security settings as a member
of the Admins group
' with full permissions)
Set wrkspc = CreateWorkspace("dbTemp", "adminuser", "Ker22mit")

With wrkspc
Set db = wrkspc.OpenDatabase("C:\FCM-C\FCM.mdb")
[Do function]
End with

* * * * *

This code runs with no errors until it gets to the function. If I'm
originally logged on as a regular user without the necessary
permissions, it returns a "you don't have the right permissions"
error. It's as though I'm still in the default workspace as
originally logged in. What am I missing?

_____________________________

Rick Brandt said:
Carol Giannini wrote:
Is it possible, for the purposes of one function that requires
administrative permissions, to reset the current user to Admin,
execute the function, and then require the user to log in again?

Many thanks in advance -- I don't post much but read a lot and the
help on this forum is phenomenal.

Not exactly, but you can open a new Workspace object and then
within that Workspace you can open another Database object using a
different user's credentials.

Dim ws As Workspace

Set ws = CreateWorkspace("MyWorkspace", "UserName", "Password")
ws.OpenDatabase "path to file"
....

You could prompt for the password so that only a user who knew it
could run the function, but you would not have to "log back in" to
revert back to the original user. Once the workspace object went
out of focus at the end of the fucntion all activities would revert
back to the original user.
 
C

Carol Giannini

Well, at least I've figured out it's not going to be simple! Actually, I'm
not even sure I can do what I want to do.

This is a normal split application, with the FE database FCM.mdb linked to
BE tables on the server. Each user has the FE on his/her own computer.
Several users are in outlying stations with their own servers; the BE is
easily replicated to those servers, but since they have different paths than
the design master, I have to provide a way for users to relink to the tables
on their servers when the FE is updated (which fortunately isn't very often).

Thinking this through, I realize that the code, including to open the new
workspace and the function I want to run, is contained in the FE database.
When I create the new workspace, I re-open the FE FCM.mdb. But the original
occurrence of FCM.mdb is still open in the default workspace, and I can't
close it, because that's where the code is running from. I would have to
create a new workspace; open a new occurrence of the database in the new
workspace; close the original occurence of the database in the default
workspace; and then pick up the function from the new workspace. But I can't
close the original event, because then the code stops running. At this point
I'm going in circles.

I've gotten around this in the past by allowing people to log on once as an
administrator, updating the tables, and then changing the password so they
can't do it again. But that's a PITN, too. It seems like it would be so
simple: temporarily assign the current user to the Admins group that has the
correct permissions, let him/her run the function, then delete him/her from
the Admins group. That runs into the problem that, as originally logged on,
the user doesn't have the permissions to assign him/herself to anything!

I'm back to the books, but any help, comments, advice or sympathy will be
greatly appreciated!
 
J

Joan Wild

I'm guessing here as you didn't explicitly state it, but is your function
just refreshing the links? If so, have another look at the security FAQ.

You can allow users to do this. See section 14 of the FAQ and post back if
you don't understand.
 
C

Carol Giannini

Rick -- just thought I'd let you know I solved this problem, at least for
now, by setting completely different permissions on the FE and BE. I allowed
users complete rights to the tables in the FE, and put all the restrictions
in the BE. This allows users to add and delete tables in the FE, but they
still can't, for example, delete records from the tables if they don't have
delete rights in the BE. Since the FE is distributed anyway, I figured if
they screw up by doing something dumb it's not going to hurt anything -- they
just get a new copy.

Thanks again for the help.
 
C

Carol Giannini

Because the path to the BE is different in the design master than the path to
the BE on the field servers, I can't just use the refresh link function --
can I? I haven't tested it, but logic tells me if the paths are set to
something that doesn't exist in the field, the relink will fail. Instead I
had to establish an entirely new connection. I'm sure I did it really
clunky, but by granting full permissions on the tables in the FE it works,
and users remain limited by the permissions I established on the BE. So
until I get time to streamline the connection code, it's working. Feel free
to point me in any direction you think will help. I really appreciate it.
Thanks.
 
Top