Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Were can I find out which user is logged in?
Message
From
18/01/1999 16:46:53
 
 
To
18/01/1999 09:20:03
General information
Forum:
Windows
Category:
Other
Miscellaneous
Thread ID:
00177149
Message ID:
00177355
Views:
29
>Were in the resistery can I find out who is the current user?
>
>I have found UserName in HKEY_CURRENT_USER\Network\ for the login to the various servers and drives, but I need the userid for the WorkStation, which could be different.
>
>NOS is NOVELL versions 3.11 to 4 something, if it matters

It doesn't - your best bet is not the registry, but an API call; either GetUserName() or WNetGetUser() will get the login for the workstation; WNetGetUser() can also retrieve the username for an attached device (eg, what user name logged into the server drive mapped as H:). Both are documented in the MSDN. In VFP, the prototype for WNetGetUser() and GetUserName() look like:
DECLARE INTEGER WNetGetUser IN WIN32API ;
   STRING lpName, ;
   STRING lpUserNameBuffer, ;
   INTEGER @ lpnBufferSize

cDevice = 0  && Assign a string like "F:" or "LPT3: " to check
             && the network connection to the device
cBuf = SPACE(256)
nBufSize = 256
IF WNetGetUser(cDevice , @cBuf, @nBufSize) = 0
   *  it worked
   ? 'User is ' + LEFT(cBuf, MAX(0,nBufSize-1))
ENDIF

DECLARE INTEGER GetUserName IN WIN32API ;
   STRING lpBuffer, ;
   INTEGER @ lpSize
cBuf = SPACE(256)
nBufSize = 256
IF GetUserName(@cBuf, @nBufSize) # 0
   *  it worked
   ? 'User is ' + LEFT(cBuf, MAX(0,nBufSize-1))
ENDIF
You can also use the Wscript.Network object's UserName property if the Windows Scripting Host has been installed.

>
>thank you
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform