Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# User Name vs VFP User Name
Message
General information
Forum:
C#
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01675446
Message ID:
01675539
Views:
83
In FoxPro you should use SYS(1) to get the username.

>In C# using Environment.UserName returns the name of the server. Same value no matter who is logged in.

Doing what exactly? A Web application? Logged in via RDP? Those things affect the host identity and don't behave the same as a local account running on a local machine.

IOW, Environment.UserName is the correct thing to use in a desktop application, but it gets you the underlying Windows identity that the process runs under.

In .NET there execution contexts though - Web applications have their own context so they support also have a logged in security for example, which is set separately based on an HTTP login (ie. HttpContext.Current.User.Identity?.Name).

IOW, context matters...

+++ Rick ---

>Hi,
>
>I find that it is much easier to get username currently logged into the PC using VFP and C#.
>
>In VFP a call to GetEnv("UserName") returns the username of the person currently logged into the PC. Works well.
>
>In C# using Environment.UserName returns the name of the server. Same value no matter who is logged in.
>
>How could I get the username using C#?
>
>TIA
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform