Ok Lads,
I confess that I didn't do any reasearch before putting the question here.
I did after and I did find something that did the trick.
I am pasting here as it could be of help for other people.
Cheers,
-----------------------------------------------------------------------------
Private Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Command1_Click()
MsgBox NTDomainUserName()
End Sub
Public Function NTDomainUserName() As String
Dim strBuffer As String * 255
Dim lngBufferLength As Long
Dim lngRet As Long
Dim strTemp As String
lngBufferLength = 255
lngRet = GetUserName(strBuffer, lngBufferLength)
strTemp = UCase(Trim$(strBuffer))
NTDomainUserName = Left$(strTemp, Len(strTemp) - 1)
End Function
|