|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Default CurrentUser when not opening formI found a peculiar situation with my database. When I first use CurrentDB and then show Workspaces(0).UserName in a MsgBox, I get the name of the logged in user. However, when I do not first access CurrentDB and ask for the value of Workspaces(0).UserName right away, I get "admin"... Further investigation reveals that "admin" really is the logged in user from then on, at least as far as Access is concerned. When I insert the following code: Dim oThisDB As DAO.Database Set oThisDB = CurrentDb right before the part where I start using Workspaces(0), all is fine and the correct current user is recognized again... Sometimes in my code I first use Workspaces(0) to get some things done before using CurrentDB. And since "admin" has no rights on my database, all my error routines get triggered. I know I can work around this issue by first asking for CurrentDB, but I wondered what might be going on... Is this by design or is there something else going on? I use Access 2003, Dutch edition, and the current user logs in via a shortcut that specifies the workgroup, username and password. Thanks in advance, Carl Colijn Try using the CurrentUser() function in the place of Workspaces(0).UserName.
-- Show quoteHide quoteLynn Trapp MS Access MVP www.ltcomputerdesigns.com Access Security: www.ltcomputerdesigns.com/Security.htm Jeff Conrad's Access Junkie List: http://home.bendbroadband.com/conradsystems/accessjunkie.html "Carl Colijn" <carl.col***@gmail.com> wrote in message news:6c99b$4506d06e$d55db81c$19029@news.chello.nl... > Hi group, > > I found a peculiar situation with my database. When I first use CurrentDB > and then show Workspaces(0).UserName in a MsgBox, I get the name of the > logged in user. However, when I do not first access CurrentDB and ask for > the value of Workspaces(0).UserName right away, I get "admin"... Further > investigation reveals that "admin" really is the logged in user from then > on, at least as far as Access is concerned. When I insert the following > code: > Dim oThisDB As DAO.Database > Set oThisDB = CurrentDb > right before the part where I start using Workspaces(0), all is fine and > the correct current user is recognized again... > > Sometimes in my code I first use Workspaces(0) to get some things done > before using CurrentDB. And since "admin" has no rights on my database, > all my error routines get triggered. I know I can work around this issue > by first asking for CurrentDB, but I wondered what might be going on... > Is this by design or is there something else going on? I use Access 2003, > Dutch edition, and the current user logs in via a shortcut that specifies > the workgroup, username and password. > > Thanks in advance, > Carl Colijn > Lynn Trapp wrote:
Show quoteHide quote > "Carl Colijn" <carl.col***@gmail.com> wrote in message Hi Lynn,> news:6c99b$4506d06e$d55db81c$19029@news.chello.nl... >> Hi group, >> >> I found a peculiar situation with my database. When I first use >> CurrentDB and then show Workspaces(0).UserName in a MsgBox, I get >> the name of the logged in user. However, when I do not first access >> CurrentDB and ask for the value of Workspaces(0).UserName right >> away, I get "admin"... Further investigation reveals that "admin" >> really is the logged in user from then on, at least as far as Access >> is concerned. When I insert the following code: >> Dim oThisDB As DAO.Database >> Set oThisDB = CurrentDb >> right before the part where I start using Workspaces(0), all is fine >> and the correct current user is recognized again... >> >> Sometimes in my code I first use Workspaces(0) to get some things >> done before using CurrentDB. And since "admin" has no rights on my >> database, all my error routines get triggered. I know I can work >> around this issue by first asking for CurrentDB, but I wondered what >> might be going on... Is this by design or is there something else >> going on? I use Access 2003, Dutch edition, and the current user >> logs in via a shortcut that specifies the workgroup, username and >> password. Thanks in advance, >> Carl Colijn > > Try using the CurrentUser() function in the place of > Workspaces(0).UserName. Well, it's not that I need the name of the CurrentUser, but I need to use the default workspace (Workspaces(0)). And directly accessing the default workspace before accessing CurrentDB results in "admin" being the current user from then on during the rest of the session, in stead of the actually logged in user. And it's not only that the name is wrong; the code also operates under the credentials of the "admin" user (which is locked out of the DB in my case). Any ideas? For now I execute the function Public Function SetCorrectUser() As Boolean Dim oThisDB As DAO.Database Set oThisDB = CurrentDb SetCorrectUser = True End Function in an AutoExec macro (which also does the trick). But I'd rather not have to rely on this workaround... Kind regards, Carl Colijn Carl,
Without using the CurrentDB reference you aren't going to know the user logged in to Workspaces(0). However, CurrentUser() should return the logged in user regardless. -- Show quoteHide quoteLynn Trapp MS Access MVP www.ltcomputerdesigns.com Access Security: www.ltcomputerdesigns.com/Security.htm Jeff Conrad's Access Junkie List: http://home.bendbroadband.com/conradsystems/accessjunkie.html "Carl Colijn" <carl.col***@gmail.com> wrote in message news:8ed4e$4506e26d$d55db81c$4006@news.chello.nl... > Lynn Trapp wrote: >> "Carl Colijn" <carl.col***@gmail.com> wrote in message >> news:6c99b$4506d06e$d55db81c$19029@news.chello.nl... >>> Hi group, >>> >>> I found a peculiar situation with my database. When I first use >>> CurrentDB and then show Workspaces(0).UserName in a MsgBox, I get >>> the name of the logged in user. However, when I do not first access >>> CurrentDB and ask for the value of Workspaces(0).UserName right >>> away, I get "admin"... Further investigation reveals that "admin" >>> really is the logged in user from then on, at least as far as Access >>> is concerned. When I insert the following code: >>> Dim oThisDB As DAO.Database >>> Set oThisDB = CurrentDb >>> right before the part where I start using Workspaces(0), all is fine >>> and the correct current user is recognized again... >>> >>> Sometimes in my code I first use Workspaces(0) to get some things >>> done before using CurrentDB. And since "admin" has no rights on my >>> database, all my error routines get triggered. I know I can work >>> around this issue by first asking for CurrentDB, but I wondered what >>> might be going on... Is this by design or is there something else >>> going on? I use Access 2003, Dutch edition, and the current user >>> logs in via a shortcut that specifies the workgroup, username and >>> password. Thanks in advance, >>> Carl Colijn >> >> Try using the CurrentUser() function in the place of >> Workspaces(0).UserName. > > Hi Lynn, > > Well, it's not that I need the name of the CurrentUser, but I need to use > the default workspace (Workspaces(0)). And directly accessing the default > workspace before accessing CurrentDB results in "admin" being the current > user from then on during the rest of the session, in stead of the actually > logged in user. And it's not only that the name is wrong; the code also > operates under the credentials of the "admin" user (which is locked out of > the DB in my case). > > Any ideas? For now I execute the function > Public Function SetCorrectUser() As Boolean > Dim oThisDB As DAO.Database > Set oThisDB = CurrentDb > SetCorrectUser = True > End Function > in an AutoExec macro (which also does the trick). But I'd rather not have > to rely on this workaround... > > Kind regards, > Carl Colijn > |
|||||||||||||||||||||||