Get User Name with NO windows security

D

Dan

Hi:

Anyone knos how do you make/incorporate this code into a
form...I was
trying and is not working! what am I missing

Thanks,

Dan
Private Declare Function apiGetUserName Lib "advapi32.dll"
Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As
Long) As Long

Function fOSUserName() As String
' Returns the network login name
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 = vbNullString
End If
End Function
 
V

Van T. Dinh

Do you mean the users don't have to log in to use you network?

If that the case, how do you expect Windows OS to know which user using the
workstation?
 
Top