Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How reliable/secure are getenv('User') & WScript.Network
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00953302
Message ID:
00954634
Views:
15
Thanks for your input Sergey.

I did try this and it definitely returned the local username. However, it only seems to return the name I used to log into the local workstation. If I log into a local workstation as "Rodd" and then log into our domain as "Rodd Harris", I will only get the user name of "Rodd".

Is there any way to return the username for a specific domain? In other words, if a user is logged into 2 domains and the local machine each with a different user name, is there any way to get the user name used for logging in to domain x? (X being whatever domain we're after).

Rodd

>Rodd,

>
>You can use WNetGetUser Win API.
>* Function GetUserName
>* Returns Windows user name
>
>LOCAL lcBuffer, lnSize, lnRetCode, lcUserName
>lcBuffer = REPL(CHR(0),64)
>lnSize = LEN(lcBuffer) -1
>DECLARE LONG WNetGetUser IN "mpr.dll"  ;
>	STRING lpName , STRING @lcBuffer, LONG @lnSize
>lnRetCode = WNetGetUser("", @lcBuffer, @lnSize )
>lcUserName = LEFT(lcBuffer, AT(CHR(0), lcBuffer)-1)
>RETURN lcUserName
>
>>GetEnv() and WScript.Network both rely on Environment variables to obtain the user and domain information. How secure is that? Aren't environment variables easily created/destroyed/edited?
>>
>>We're wanting to use the credentials with which the user logged in for our applications security so that the user does not have to log into their workstation and then turn around and log into our app. We've talked about pulling the information from GetEnv or WScript but if users can "tweak" environment variables then that would allow them to spoof other users, etc.
>>
Previous
Reply
Map
View

Click here to load this message in the networking platform