Getting the full user name under Win NT 
Author Message
 Getting the full user name under Win NT

Hello

In VB 4 or VB 5, I need to get the full user name in Windows NT.

I've already gotten the account name by calling WNetGetUser, but I need to
get the data from the Full Name field from the NT User Manager.

I know that it's possible to do in C++, but I was having trouble porting
the code to VB. Does anyone have any experience/ideas/code?

Thanks,

--
Ilya Haykinson



Tue, 28 Sep 1999 03:00:00 GMT  
 Getting the full user name under Win NT

This code is courtesy of Jeff Hong YAN.  Enjoy.

Type TUser11
     ptrName        As Long
     ptrComment     As Long
     ptrUsrComment  As Long
     ptrFullName    As Long
     dwPriv         As Long
     dwAuthFlags    As Long
     dwPasswordAge  As Long
     ptrHomeDir     As Long
     ptrParms       As Long
     dwLastLogon    As Long
     dwLastLogoff   As Long
     dwBadPwCount   As Long
     dwNumLogons    As Long
     ptrLogonServer As Long
     dwCountryCode  As Long
     ptrWorkstations    As Long
     dwMaxStorage   As Long
     dwUnitsPerWeek As Long
     ptrLogonHours  As Long
     dwCodePage     As Long
End Type    '} USER_INFO_11, *PUSER_INFO_11, *LPUSER_INFO_11;

Function GetUserFullName(sUserID As String) As String

    Dim swServer    As String * 255
    Dim swUserID    As String * 255
    Dim lReturn     As Long
    Dim ptmpBuffer  As Long
    Dim ptr         As Long
    Dim sUserFullName As String

    Dim sUser As String
    Dim sByte() As Byte
    ReDim sByte(255)

    swUserID = StrConv(sUserID & vbNullChar, vbUnicode)
    swServer = StrConv(vbNullChar, vbUnicode)

    Dim tmpBuffer As TUser11

    lReturn = MyNetUserGetInfo(swServer, swUserID, 11&, ptmpBuffer)

    RtlMoveMemory tmpBuffer, ptmpBuffer, LenB(tmpBuffer)

    ptr = tmpBuffer.ptrFullName
    If ptr <> 0 Then
        RtlMoveMemory sByte(0), ptr, 256
        sUser = vbNullString
        sUser = sByte
        sUser = sUser & vbNullChar
    Else
        sUser = "(Unknown)"
    End If

    sUserFullName = Left$(sUser, InStr(sUser, Chr$(0)) - 1)

    Call NetAPIBufferFree(ptmpBuffer)

    Debug.Print "Full Name = " & sUserFullName
    GetUserFullName = sUserFullName
End Function



Quote:
> Hello

> In VB 4 or VB 5, I need to get the full user name in Windows NT.

> I've already gotten the account name by calling WNetGetUser, but I need
to
> get the data from the Full Name field from the NT User Manager.

> I know that it's possible to do in C++, but I was having trouble porting
> the code to VB. Does anyone have any experience/ideas/code?

> Thanks,

> --
> Ilya Haykinson




Tue, 28 Sep 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Getting the user full name from SAM.

2. Getting The Full Domain User Name In Win95

3. Full user name from NT login ID

4. Reading NT Full name from a user account

5. How can I read the USER NAME (Win NT) with VBScript

6. getting windows NT user name

7. Getting NT Users LOGIN NAME?

8. Getting NT User Name in VBScript

9. Getting NT User Login Name

10. Getting user names on NT domain

11. getting NT user names

12. Getting the NT User Name

 

 
Powered by phpBB® Forum Software