Getting Username

BlitzMax Forums/BlitzMax Programming/Getting Username

Glenn Dodd(Posted 2008) [#1]
I used to have some VBA code that i used in an access database. When someone opened the database it checked for the username (nt login name?) and i was able to use it as a field in my queries to allow/disallow different functions or screens.

Does anyone have something similar for use in Blitzmax?
Ideally a cross platform bit of code would be best, but i don't know anything about the other 2 platforms. Maybe there are separate ways to do this on Mac and Linux?

If it isn't possible then i will go back to making the user logon to the application.

Cheers
Glenn


Brucey(Posted 2008) [#2]
If you were using wxMax, I might suggest wxGetUserId() and wxGetUserName().

Otherwise, you'll need to investigate the API's for each system.

For example, on Linux/Mac you can use the commandline "who", but you can also use "who am i", which may return a different value depending on who you were originally logged in as - yes, you can change to different users on the fly :-)


Glenn Dodd(Posted 2008) [#3]
that's exactly what i am after.

many thanks again


Glenn Dodd(Posted 2008) [#4]
just scanned the userguide and the help for wxwidgets.
what section is this in?


Glenn Dodd(Posted 2008) [#5]
not to worry.
it seems i don't need to import anything to get it working...


Brucey(Posted 2008) [#6]
It's part of core.

MaxIDE *really* needs a searchable indexed help...


JazzieB(Posted 2008) [#7]
No need to use a third party module...

username:String=getenv_("USERNAME")

does it for Windows and Linux. Replace "USERNAME" with "USER" for Mac.


Brucey(Posted 2008) [#8]
except USER is not set in stone.

> echo $USER
brucey

> export USER=bob
> echo $USER
bob

> whoami
brucey