Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect who the user is 1

Status
Not open for further replies.

GKatReliable

Programmer
Jul 2, 2002
45
0
0
US
We have FPW26 and run a number of programs against our payroll system. We keep an audit text file of what gets run by our user community. Each program passes parameters to this function, which writes to the audit text file:
FUNCTION LogWrit
PARAMETER lcText, lcLog
IF PCOUNT() < 2 .OR. lcLog = ''
lcLog = 'AUDIT.TXT'
ENDIF
SET CONSOLE OFF
SET ALTERNATE TO &lcLOG ADDITIVE
SET ALTERNATE ON
? LEFT(CDOW(DATE()),3), DATE(), TIME(), lcText
SET ALTERNATE TO
SET ALTERNATE OFF
SET CONSOLE ON
RETURN
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The lcText is the name of the program that is running at the time.
Anyway, what we really need to be able to add to this, is who the user is that is running the program at the time. We have Windows NT-type network and servers and NT/Win2K PCs. dBase used to have a couple functions to tell the user ID, but I can't find anything in FPW26.
Keeping things simple would be a good thing.
Regards,
Glenn Koproske
St. Louis, Missouri
 
See if getenv() works for you.

? getenv("computername")
? getenv("username")

Computername and username are environment variables.
 
For a Payroll System, you might want to consider implementing a Login & Password entry utility.

In that way, you will not get erroneous user data if someone is using another person's workstation. Not to mention limiting access to functionality - partial or total.

Then the Login name can be used throoughout the program as a PUBLIC variable in any way desired.

There are a number of previous postings within this forum about Login utilities.

Good Luck,


JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
FoxPro 2.6 does have the ID() function, but it returns only the computer name (indicating the physical location) on Windows networks, as I've tested it on a Windows 2000 server network. I'm not absolutely sure of this, but I think if the network is Novell Netware then it will return the logged in username. At least it used to.

It is good that you're using Windows NT-family workstations since those systems do, as TheRambler said, have the SET variables for computername and username. (To see the entire list of variables that can be read, open a DOS or Command Prompt windows and type SET.) Windows 95/98/Me do not have those. So jrbbldr's suggestion to build in a login process into your application would be necessary if some of those older systems were in use.

By the way, don't forget that support for Windows NT is being phased out and will end at the end of 2004. That's just one of several reasons to upgrade any NT4 systems and servers to at least Windows 2000 or newer.

dbMark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top