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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VPN blocking the API apiGetUserName

Status
Not open for further replies.

tweetyangel00

Technical User
Feb 3, 2011
6
US
Hello,
I am using the following function to capture the user ID from the network. It works fine if you are plugged into the network but if you are connected to the network through a VPN connection the user ID does not show up at all. Is there a way around this?

************************************************
Public Function fOSUserName() As String
On Error GoTo fOSUserName_Err

Dim lngLen As Long, lngX As Long
Dim strUserName As String

strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)

If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If

'Debug.Print fOSUserName

fOSUserName_Exit:
Exit Function

fOSUserName_Err:
MsgBox Error$
Resume fOSUserName_Exit
End Function
************************************************
Thank you!
 
WNetGetUser instead?

55,687.00 hours down....
82 hours to go

tick tick tick tick tick
 
What about Environ("USERNAME") ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I am curious. Does USERNAME work in this case?

55,687.00 hours down....
<60 hours to go

tick tick tick tick tick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top