Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding out who the user is...
Message
From
27/01/1999 10:30:28
 
 
To
27/01/1999 09:45:17
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00178748
Message ID:
00180769
Views:
27
>Ed,
>
>Here is the function as I've tried to use it. Calling it with
>GetUser("C:")
>GetUser("V:") (mapped drive)
>GetUser("æøå") (garbage)
>all returns my username...
>
>
>* FUNCTION GetUser
>
LPARAMETERS ltcResource
>LOCAL lcResource, lcUserId, lnLen
>
>IF TYPE("ltcResource") = "C"
>	lcResource = ltcResource
>ELSE
>	lcResource = ""
>ENDIF
>lcUserId = SPACE(255)
>lnLen = 255
>
>* Use the WNetGetUser function in the Win32API to get the user id
>DECLARE INTEGER WNetGetUser IN WIN32API String @, String @, Integer @
>IF WNetGetUser(lcResource + CHR(0), @lcUserId, @lnLen) = 0
> lcUserId = UPPER(LEFT(lcUserId, AT(CHR(0), lcUserId) - 1))
>ELSE
> lcUserId = ""
>ENDIF
>
>RETURN ALLTRIM(lcUserId)
>
>

What operating system are you using, and what userid was used to attach the networked resource? I did see that Win98 returned my domain ID for anything other than null, which returned my local Windows login; NT seems to behave as per the documentation in the MSDN, but Win9x is not behaving as expected it seems.

If you're running in a peer-to-peer environment, I'd say that your results were correct, since you'd have share-level access rather than user-level access enabled, which means that your userid for all connections is the same. Why local and non-existent connections are returning any value without an error doesn't make sense.
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