aluiken
asked on
Network login name
Hi there,
Is there a way to find out the currently logged in user name for microsoft networking (so NOT the windows password?)
Cheers
Is there a way to find out the currently logged in user name for microsoft networking (so NOT the windows password?)
Cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I was too late, just ignore my post
By the way, here's another way:
Private Declare Function WNetGetUserA Lib "mpr" (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long
Function GetUserID() As String
Dim lName As String * 255
lName = Space(255)
Call WNetGetUserA(vbNullString, lName, 255&)
GetUserID = Left$(lName, InStr(lName, vbNullChar) - 1)
End Function
Private Sub Command1_Click()
MsgBox GetUserID
End Sub
Cheers!®©
Private Declare Function WNetGetUserA Lib "mpr" (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long
Function GetUserID() As String
Dim lName As String * 255
lName = Space(255)
Call WNetGetUserA(vbNullString,
GetUserID = Left$(lName, InStr(lName, vbNullChar) - 1)
End Function
Private Sub Command1_Click()
MsgBox GetUserID
End Sub
Cheers!®©
ASKER
Very good, thx
Thanks for the points! Glad I could help!
Cheers!®©
Cheers!®©
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
and then just call it eg:-
GetUserName strUser, 10
lpbuffer is the string that you want the username to go into and nSize is the length of the string.
hope this helps
Jetforce