VFP6-Getting logged in user name? 
Author Message
 VFP6-Getting logged in user name?

Cole,

Try the following

*//---------------------------------------------------------------------------------------------------------------------
FUNCTION GET_USERNAME

LOCAL lcUserName, llReturn

llReturn = .F.
lcUserName = GETENV("USERNAME")

*// Additional Testing for Windows Version is probably appropriate, also
*// Test for NetWare Env Variables for NetWare Clients

IF NOT EMPTY(lcUserName)
    WAIT WINDOW "Currently Logged In User: " + TRIM(lcUserName)
    llReturn = .T.
ELSE
    llReturn = .F.
ENDIF

*// Could Return UserName - Whatever? - Otherwise

RETURN (llReturn)

*//---------------------------------------------------------------------------------------------------------------------

HTH

John Gunvaldson
Fox/Net West
San Diego, CA

HTH

I would like to know who is logged into the win95/98/NT workstation when my VFP app starts, so I can present the correct menu.

So far my searches haven't turned up a method of finding out.

Any suggestions?

Thanks for any help.

Cole




Sun, 03 Jun 2001 03:00:00 GMT  
 VFP6-Getting logged in user name?
Cole,

The windows api for this is simple (for an api call :-), but I use focus.fll
for this at www.fastwrite.com.

John.

    I would like to know who is logged into the win95/98/NT workstation when
my VFP app starts, so I can present the correct menu.

    So far my searches haven't turned up a method of finding out.

    Any suggestions?

    Thanks for any help.

    Cole




Mon, 04 Jun 2001 03:00:00 GMT  
 VFP6-Getting logged in user name?
Hi,
you can use the WNetGetUser Function from Win API.

Here is an example:

function get_user
local lcuserid, lcnull, lnLen

lcUserId=space(255)
lcNull  =chr(0)
lnLen   =255



     lcUserId = upper( left( lcUserId, at(chr(0),lcUserId)-1 ) )
else
     lcUserId = ''
endif

if left(lcUserID,1)==chr(0)
     lcUserId = ''
endif

return lcUserId

Holger Vorberg
Data Consulting GmbH
Bielefeld, Germany



Mon, 04 Jun 2001 03:00:00 GMT  
 VFP6-Getting logged in user name?
Try sys(0)
It will return:
<MachineName> #<UserName>
mUserLoginName = SUBSTR(sys(0),AT('#',sys(0))+1,len(sys(0)))
mMachineName = RIGHT(sys(0),AT('#',sys(0))-1)


Mon, 04 Jun 2001 03:00:00 GMT  
 VFP6-Getting logged in user name?

It will Work in NT not in Win95
Try Sys(0) it will return machine name and user name

    Cole,

    Try the following

    *//---------------------------------------------------------------------------------------------------------------------
    FUNCTION GET_USERNAME

    LOCAL lcUserName, llReturn

    llReturn = .F.
    lcUserName = GETENV("USERNAME")

    *// Additional Testing for Windows Version is probably appropriate, also
    *// Test for NetWare Env Variables for NetWare Clients

    IF NOT EMPTY(lcUserName)
        WAIT WINDOW "Currently Logged In User: " + TRIM(lcUserName)
        llReturn = .T.
    ELSE
        llReturn = .F.
    ENDIF

    *// Could Return UserName - Whatever? - Otherwise

    RETURN (llReturn)

    *//---------------------------------------------------------------------------------------------------------------------

    HTH

    John Gunvaldson
    Fox/Net West
    San Diego, CA

    HTH


    I would like to know who is logged into the win95/98/NT workstation when my VFP app starts, so I can present the correct menu.

    So far my searches haven't turned up a method of finding out.

    Any suggestions?

    Thanks for any help.

    Cole




Mon, 04 Jun 2001 03:00:00 GMT  
 VFP6-Getting logged in user name?

 ** Returns the current User ID who is logged on to the
 ** Client PC.  For security purposes, be aware that this
 ** does not mean the User has been authenticated and has
 ** priviliedges on any network resource.  It only means
 ** that the User was entitled to logon to the local PC.
 ** For many organizations, this is acceptable
 ** identification for granting further access.  However,
 ** in a high security environment, MIS Managers would look
 ** upon this with great disdain.
 PROCEDURE LocalLogonName

  LOCAL lcUser, lnLength

  DECLARE INTEGER GetUserName IN WIN32API AS GetUser ;


  lcUser  = SPACE(30)
  lnLength = 29


  RETURN LEFT(lcUser,AT(CHR(0),lcUser)-1)

 ENDPROC

This works for me.

Guy



Tue, 05 Jun 2001 03:00:00 GMT  
 VFP6-Getting logged in user name?
Try the SYS(0) FN
This FN returns the cName_of_Computer#cUserLogin
For further information please read the manual.
Beware the differences in result between FPW and VFP.

--

mfg

Wolfgang Schmale / Germany

    Cole Cunningham schrieb in Nachricht

    I would like to know who is logged into the win95/98/NT workstation when
my VFP app starts, so I can present the correct menu.

    So far my searches haven't turned up a method of finding out.

    Any suggestions?

    Thanks for any help.

    Cole




Thu, 07 Jun 2001 03:00:00 GMT  
 VFP6-Getting logged in user name?
hey, how about the id() function?  (same as sys(0))

Quote:

>Try the SYS(0) FN
>This FN returns the cName_of_Computer#cUserLogin
>For further information please read the manual.
>Beware the differences in result between FPW and VFP.

>--

>mfg

>Wolfgang Schmale / Germany

>    Cole Cunningham schrieb in Nachricht

>    I would like to know who is logged into the win95/98/NT workstation
when
>my VFP app starts, so I can present the correct menu.

>    So far my searches haven't turned up a method of finding out.

>    Any suggestions?

>    Thanks for any help.

>    Cole





Sun, 10 Jun 2001 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Getting user name and domain name using VFP

2. VFP getting User Id and/or Name

3. Getting Network user name in Win95

4. Getting Network user name.

5. Getting user name

6. Getting user name in win95 for 2.6

7. Logging users off unattended workstations

8. User logged on

9. How To Find Number Of Users Logged In?

10. exe each time the users log to the network

11. User Action Logging or Tracking Strategies?

12. Logging off user

 

 
Powered by phpBB® Forum Software