current login

J

Jason

Hi,

I was wondering how i could use the current login in a textbox. I know the
currentuser() gives me e.g. 'Admin' if no security is set up.

But how can i get the login and/or hostname from windows (or if logged in
through novell)?

Greetings,

J
 
N

Nikos Yannacopoulos

Jason,

Not sure if this will work under Novell, but as far as Windows goes:

Environ("UserName")

will return the Windows login name.

It can be argued that environment variables are fairly easy to change,
so some advise to use an API call instead, in order to retrieve the
Windows login name. The counter-argument is that hardly any user will
know how to do that, even if they know it's being used, but if you want
to go by the book you can find the code in:

http://www.mvps.org/access/api/api0008.htm

HTH,
Nikos
 
J

Jason

Hi Nikos,

Thanks for tip. I agree that normal users don't know how to change it. Do
you also know to get the hostname?

Greetings,

J
 
D

Douglas J. Steele

Recognize, though, that not all of the environment variables listed in that
article necessarily exist on all machines. I stopped comparing after about 5
in the list weren't present on my machine.

Recognize, too, that it's trivial to reset any environment variable
(although doing so may cause problems on the machine)
 
N

Nikos Yannacopoulos

Doug,

First point is fair. Second one as well, but I've already warned Jason
about it! I have to admit I don't know how to change an environment
variable, so I trust my users )whom I know) won't either. Speaking of
it, how is it done?

Thanks,
Nikos
 
B

Barry-Jon

Yes - how is it done? Any way of knowing that's it's been done and use
the API call if it has?
 
D

Douglas J. Steele

It can be as simple as opening a command prompt and issuing a Set command:

Set UserName=Phoney

There are also API calls that let you set environment variables.

If you're going to try and detect whether it's been done and use the API it
is has, why not just use the API everytime?
 
Top