Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting name and email from AD
Message
From
21/07/2022 00:02:03
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01684680
Message ID:
01684684
Views:
49
>>Hi,
>>
>>In my ASP.NET application, MS .NET Framework has a class that allows to get a user name and email by AD username.
>>
>>Could the same be done in VFP 9?
>>
>>That is, user would enter his/her AD username (e.g. "j_smith") and the VFP application would connect to the AD (using the entered username) and get this user name and email?
>>
>>Let me know if you have done something like this
>>
>>TIA
>
>The approach suggested by Tamar is nice. But the customer won't want my VFP application to SQL Select all records from the AD. Instead they want the application to "know" - or determine - the AD username currently logged into the PC.
>
>That is, suppose when a user logs into his/her PC, they enter the AD username "j_smith" (as an open text) and enter the password (of course, covered with asterisks). Then, they want my VFP application to determine (how is a big question) that the current AD username (logged into the PC) is j_smith.
>
>Is the above possible?

When a user signs in to on-premises AD, several environment variables are set:
USERDNSDOMAIN
USERDOMAIN
USERNAME

You could retrieve these with GETENV(). Bear in mind these can be modified by the user so they're not reliable in an adversarial situation.
There are also the old ID( ) and SYS( 0 ) functions. I'm not sure if these return the correct username if the user modifies the environment variables.

I haven't tested any of the above for a user sign in to Azure Active Directory (AAD), if that applies in your case. I suspect not, since those usernames are of the format someuser@somedomain.com .
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform