Login Information

How can I get the username for the person logged into the server (winnt/win95/win98) from VB? I need to validate the user to allow different levels to access different parts of the program without having them re-login or keeping a password list.
dtyson010799Asked:
Who is Participating?
 
myqlGConnect With a Mentor Commented:
Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

and where ever you want to check it (ill use a command button)
Private Sub Command1_Click()
Dim x As String, y As Long
x = Space$(255)
 y = 255
 GetUserName x, y
x = Left$(x, y)
MsgBox x
End Sub

0
 
dtyson010799Author Commented:
Thanks
That was exactly what I was looking for.
0
 
soyapiCommented:
Yes! How to validate user so no access deny.
0
All Courses

From novice to tech pro — start learning today.