Attribute VB_Name = "modIsLocalAdmin"
Private Declare Function NetUserGetInfo Lib "netapi32" (ByVal ServerName As String, ByVal UserName As String, ByVal Level As Long, bufptr As Long) As Long
Private Const NERR_Success = 0
Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal dwLength As Long)
Private Declare Function NetApiBufferFree Lib "netapi32" (ByVal Buffer As Long) As Long

Private Const USER_PRIV_GUEST = 0
Private Const USER_PRIV_USER = 1
Private Const USER_PRIV_ADMINISTRATOR = 2

Private Type USER_INFO_3
    usri3_name As Long
    usri3_password As Long
    usri3_password_age As Long
    usri3_priv As Long
    usri3_home_dir As Long
    usri3_comment As Long
    usri3_flags As Long
    usri3_script_path As Long
    usri3_auth_flags As Long
    usri3_full_name As Long
    usri3_usr_comment As Long
    usri3_parms As Long
    usri3_workstations As Long
    usri3_last_logon As Long
    usri3_last_logoff As Long
    usri3_acct_expires As Long
    usri3_max_storage As Long
    usri3_units_per_week As Long
    usri3_logon_hours As Long
    usri3_bad_pw_count As Long
    usri3_num_logons As Long
    usri3_logon_server As Long
    usri3_country_code As Long
    usri3_code_page As Long
    usri3_user_id As Long
    usri3_primary_group_id As Long
    usri3_profile As Long
    usri3_home_dir_drive As Long
    usri3_password_expired As Long
End Type

Public Function IsUserAdmin(p_strUserName As String) As Boolean
Dim udtUSER_INFO As USER_INFO_3
Dim lngBufferPointer As Long

IsUserAdmin = False

If (NetUserGetInfo("", StrConv(p_strUserName, vbUnicode), 3, lngBufferPointer) = NERR_Success) Then
Call MoveMemory(udtUSER_INFO, ByVal lngBufferPointer, Len(udtUSER_INFO))
Call NetApiBufferFree(ByVal lngBufferPointer)

        
If udtUSER_INFO.usri3_priv = USER_PRIV_ADMINISTRATOR Then
IsUserAdmin = True
End If
End If
End Function

