Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Environ function doesn't work in VPN setup

Status
Not open for further replies.

MDTekUser

Technical User
Dec 25, 2005
68
0
0
US
I have an application where I'm authenticating the user based on their windows logon at startup.

This works great except for VPN users offsite have complained that they are not able to be authenticated even though they are using the same logon as they would normally.

I'm using the Environ("UserName") variable. Does anyone know a fix for this or an alternate solution? Thanks...
 
From what I have researched this may be because the user doesn't have the environment variables set on their computer.

In that case I might just use the GetUserName API call instead.

I would still like to know why the Environ function isn't working...
 
For this and other reasons, use what mdtekuser suggested...
Here are the declares for two common api's used for authentication:
Code:
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Declare Function GetComputerName Lib "kernel32.dll" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
--Jim
 
Environ("Username") works on any 2K or XP computer; I bet the problem is that you're expecting it to return their "vpn username" instead of their "Windows username" which is outside of your control. Getting their VPN username is probably not possible (as far as I know, there's no VPN standard, which means there's no standard library to figure out their username). Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top