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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Any way to ID the user ? 1

Status
Not open for further replies.

jerrytvspec

Technical User
Dec 1, 2001
15
US
Is there any command on a fox-pro multi user to detect what user is using the program? That way I could cutomize certain screens just for that user.
 
Provided there is a system variable something like USERNAME or LOGINNAME, which is usually set by a login script, you can use:

cUser = GETENV("USERNAME") or
cUser = GETENV("LOGINNAME")

to determine the user. If you create a login screen of some sort, you could obtain the user from that. If you are distributing to some unknow user or system, you may have to get some registered user info from the system registry using api calls.

Dave S.
 
A pure VFP solution is to use SYS(0). In Win95/98/NT/2000/XP it will return
&quot;<computer name> # <user name>&quot;. Just grab what you need.

Under NT/2000/XP these also work:
?getenv(&quot;COMPUTERNAME&quot;) && same as first part of SYS(0)
?getenv(&quot;USERNAME&quot;) && same as second part of SYS(0)
?getenv(&quot;USERDOMAIN&quot;)

Or using WSH - Comes with 98/2000/XP, probably on most 95/NT systems (can be installed if missing):
oObj = createobject(&quot;wscript.network&quot;)
? oObj.UserName
? oObj.ComputerName
? oObj.UserDomain

Rick

Rick
 
Note: The WSH (Windows Script Host) solution above only works in Visual FoxPro - I forgot which forum I was on (sorry)!

Rick
 
We use a library called GPLIB which is available for both Foxpro 2.6 and Visual Fox Pro. This library allows you to detect the USERS login ID and check their network login against their network password. We use Netware 5 as our network software.

The library is sold commercially so I can't send you a copy. You can get more information on
 
*+ Returneaza numele user-ului curent (asa cum a intrat el in windows)
*------------------------------------------------------------------ NwGtWiUI
* Functia NwGtWiUI
* Versiune 1.0 09.05.2000 Mihai Cazac
*
* Descriere Returneaza numele user-ului curent
* Context
* Fpw26a / Windows 9x
* Set Library To FoxTools.FLL Additive
* Intrari
* Parametrii
* Variabile globale
*
* Iesiri
* Variabile globale
*
* Returneaza sir de maximum 40 de caratere
*
* Functii apelate
* CallFn, RegFn - FoxTools
* WNetGetUser - Win32API
*
*
*-----------------------------------------------------------------
Function NwGtWiUI && NetWorkGeTWindowsUserId
*
* Declaratii de variabile locale
*

*
* Parametrii pentru apel WNetGetUser
*
Private LocalName && NUL daca se doreste pt calc.curent
Private UserName && Loc returnare Nume utilizator
Private BufferSize && Dimensine maxima buffer
Private fhWNetGetUser && Handler functie
*
* Initializari
*
LocalName = Replicate(Chr(0),16) && Vreau de pe masina curenta
UserName = Replicate(Chr(0),255) && Asigur Spatiu suficient
BufferSize = Len(UserName)
*
* Cod efectiv
*
fhWNetGetUser = RegFn(&quot;WNetGetUser&quot;,&quot;@C@C@I&quot;,&quot;I&quot;) && Inregistrez functia (din Win32API)
If fhWNetGetUser = -1 && daca nu poate, returnez totusi ceva
UserName = &quot;Nu pot inregistra WNetGetUser&quot;
Else && Inregistrata, o apelez cu parametrii
=CallFn(fhWNetGetUser, @LocalName, @UserName, @BufferSize)
EndIf

Return (AllTrim(StrTran(UserName,CHR(0))) ) &&NwGtWiUI()


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top