Click to See Complete Forum and Search --> : NetWorking VFP 6
Rafael Rangel
03-21-2000, 04:15 PM
I am working in VFP 6.0. Is there a way to know the User Name, or Station,
connected to the network?. I need, from my program, get the user that logon
or logoff the network, to log that in a dbf file.
I am in a Windows NT environment. Thanks
John C. Gunvaldson
03-21-2000, 05:55 PM
Lots of things,
One of the easiest is to use the following in a Custom Method:
*// Local Variables
LOCAL lcReturn, lcNTUser, lc98User, lcOsVer
*// Default Assignments
lcReturn = DODEFAULT()
lcOsVer = OS()
lcNTUser = ""
lc98User = ""
*// ID User's Operating System - and Determine Login Name
DO CASE
CASE "NT" $ ALLTRIM(UPPER(lcOsVer))
lcUser = IIF(NOT EMPTY(GETENV('USERNAME')), ;
GETENV('USERNAME'),GETENV('USER'))
CASE "98" $ ALLTRIM(UPPER(lcOsVer))
lcUser = IIF(NOT EMPTY(GETENV('USER')), ;
GETENV('USER'),GETENV('S_FILE'))
CASE "95" $ ALLTRIM(UPPER(lcOsVer))
lcUser = IIF(NOT EMPTY(GETENV('USER')), ;
GETENV('USER'),GETENV('S_FILE'))
OTHERWISE && Try to retrieve NetWare Info
lcUser = IIF(NOT EMPTY(GETENV('USER')), ;
GETENV('USER'),GETENV('LOGIN_NAME'))
ENDCASE
*// Store - and modify Case - if Needed
IF NOT EMPTY(lcUser)
THIS.VALUE = ALLTRIM(lcUser)
ENDIF
*// Back
RETURN (lcReturn)
hth
John C. Gunvaldson
CNE, MCP(x5)
San Diego, CA
"Rafael Rangel" <rrangel@data-lock.com> wrote in message
news:38d7d873$1@news.devx.com...
>
> I am working in VFP 6.0. Is there a way to know the User Name, or Station,
> connected to the network?. I need, from my program, get the user that
logon
> or logoff the network, to log that in a dbf file.
> I am in a Windows NT environment. Thanks
Garrett Fitzgerald
03-21-2000, 08:59 PM
In article <38d7ed20$1@news.devx.com>, foxnet_west@hotmail.com (John
C. Gunvaldson) quoth...
> CASE "NT" $ ALLTRIM(UPPER(lcOsVer))
> lcUser = IIF(NOT EMPTY(GETENV('USERNAME')), ;
> GETENV('USERNAME'),GETENV('USER'))
http://support.microsoft.com/support/kb/articles/q250/5/12.asp
--
Garrett Fitzgerald
#INCLUDE "\Program Files\Microsoft Visual Studio\VFP98\stddsclm.h"
(Anyone who thinks I do anything vaguely resembling speaking for Microsoft
is sorely deluded...)
John C. Gunvaldson
03-22-2000, 06:45 PM
Hmmm,
Based upon Garrett finding the Windows 2000 info kb, one might
want to create new version of Login Name environment catcher
as follows?
*//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*// Local Variables
LOCAL lnSelect, lcReturn, lcUser
*// Default Assignments
lnSelect = Select()
llReturn = DoDefault()
lcUser = ""
*// ID User's OS - Obtain Env. Variable For User
Do Case
*// Tests for Windows 2000 or NT 4.0
Case "5.00" $ OS() OR "NT 4.00" $ OS()
lcUser = IIF(NOT EMPTY(GETENV('USERNAME')), ;
GETENV('USERNAME'),GETENV('USER'))
*// Tests for Windows 98 or 95
Case "4.00" $ OS() OR "4.10" $ OS()
lcUser = IIF(NOT EMPTY(GETENV('USER')), ;
GETENV('USER'),GETENV('S_FILE'))
*// Try to retrieve NetWare Info?
OtherWise
lcUser = IIF(NOT EMPTY(GETENV('USER')), ;
GETENV('USER'),GETENV('LOGIN_NAME'))
EndCase
*// Could be used in a Users Login Name txtBox?
If Not Empty(lcUser)
This.value = AllTrim(lcUser)
ENDIF
*// Or - Return Value if Used as Custom Method?
Return Iff( llReturn, AllTrim(lcUser),"")
*//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Good Catch Garrett, as I use this in a legacy App, I am going back and make
updates based upon kb...
Thanks
John C. Gunvaldson
San Diego, CA
John C. Gunvaldson
03-22-2000, 07:19 PM
Ok,
^
I saw it <g> To correct Above |
1 - Have llReturn assigned a logical based upon something - dunno, maybe
empty values or something?
2 - Change Iff - to - IIF
Too fast with fingers <sigh>.... Otherwise, just checked it with Windows
2000 here - works fine.
John
Garrett Fitzgerald
03-23-2000, 03:30 AM
"John C. Gunvaldson" <foxnet_west@hotmail.com> wrote in message
news:38d94a0b@news.devx.com...
> Hmmm,
>
> Based upon Garrett finding the Windows 2000 info kb, one might
> want to create new version of Login Name environment catcher
> as follows?
Ah. I'm at home now, so I can talk. :-) As my article pointed out, the
GetVersionInfoEx() function is a better way to test 9x/NT differences. I
wrote a wonderful little class encapsulating the functionality, but TPTB
decided it duplicated Q188897 too closely. Would someone like to write it
themselves and post it here or on the Universal Thread? :-) Most of the code
is in that article -- you just need to add a little to cover everything that
function does.....
Ed Rauh
03-23-2000, 08:57 PM
SYS(0) returns the current Windows userid and NetBIOS station ID. There are
also API calls that cna be made to determine the user id other than the base
WIndows ID for a particular server using WNetGetUser() given the name of an
accessible share on the server or a local resource mapped to a specific
share.
"Rafael Rangel" <rrangel@data-lock.com> wrote in message
news:38d7d873$1@news.devx.com...
>
> I am working in VFP 6.0. Is there a way to know the User Name, or Station,
> connected to the network?. I need, from my program, get the user that
logon
> or logoff the network, to log that in a dbf file.
> I am in a Windows NT environment. Thanks
devx.com
Copyright WebMediaBrands Inc. All Rights Reserved