' ########################################################################################
' Microsoft Windows
' File: LMaccess.inc
' Contents: Structures, function prototypes, and definitions for the NetUser, NetUserModals,
' NetGroup, NetAccess, and NetLogon API.
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_LMaccess_PBI)
#DEFINE PBX_LMaccess_PBI
'//
'// User Class
'//
#IF NOT %DEF(%LMUSER)
 %LMUSER = 1
#INCLUDE ONCE "Core/Windows.inc"
#INCLUDE ONCE "Legacy/Platform/LMCons.inc"
'//
'// Function Prototypes - User
'//
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetUserAdd LIB "NetAPI32.dll" ALIAS "NetUserAdd" ( servername AS WSTRINGZ, BYVAL level AS QUAD, BYVAL buf AS BYTE PTR, parm_err AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetUserAdd LIB "netapi32.dll" ALIAS "NetUserAdd" ( BYREF servername AS WSTRINGZ , BYVAL level AS QUAD , BYREF buf AS ANY , BYREF parm_err AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetUserEnum LIB "NetAPI32.dll" ALIAS "NetUserEnum" ( servername AS WSTRINGZ, BYVAL level AS QUAD, BYVAL filter AS QUAD, BYVAL bufptr AS BYTE PTR, BYVAL prefmaxlen AS QUAD, entriesread AS QUAD, totalentries AS QUAD, resume_handle AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetUserEnum LIB "netapi32.dll" ALIAS "NetUserEnum" ( BYREF servername AS WSTRINGZ , BYVAL level AS QUAD , BYVAL filter AS QUAD , BYREF bufptr AS ANY , BYVAL prefmaxlen AS QUAD , BYREF entriesread AS QUAD , BYREF totalentries AS QUAD , BYREF resume_handle AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetUserGetInfo LIB "NetAPI32.dll" ALIAS "NetUserGetInfo" ( servername AS WSTRINGZ, username AS WSTRINGZ, BYVAL level AS QUAD, BYVAL bufptr AS BYTE PTR ) AS QUAD
#ELSE
DECLARE FUNCTION NetUserGetInfo LIB "netapi32.dll" ALIAS "NetUserGetInfo" ( BYREF servername AS WSTRINGZ , BYREF username AS WSTRINGZ , BYVAL level AS QUAD , BYREF bufptr AS ANY ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetUserSetInfo LIB "NetAPI32.dll" ALIAS "NetUserSetInfo" ( servername AS WSTRINGZ, username AS WSTRINGZ, BYVAL level AS QUAD, BYVAL buf AS BYTE PTR, parm_err AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetUserSetInfo LIB "netapi32.dll" ALIAS "NetUserSetInfo" ( BYREF servername AS WSTRINGZ , BYREF username AS WSTRINGZ , BYVAL level AS QUAD , BYREF buf AS ANY , BYREF parm_err AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
DECLARE FUNCTION NetUserDel LIB "netapi32.dll" ALIAS "NetUserDel" ( BYREF servername AS WSTRINGZ , BYREF username AS WSTRINGZ ) AS QUAD ' NET_API_STATUS
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetUserGetGroups LIB "NetAPI32.dll" ALIAS "NetUserGetGroups" ( servername AS WSTRINGZ, username AS WSTRINGZ, BYVAL level AS QUAD, BYVAL bufptr AS BYTE PTR, BYVAL prefmaxlen AS QUAD, entriesread AS QUAD, totalentries AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetUserGetGroups LIB "netapi32.dll" ALIAS "NetUserGetGroups" ( BYREF servername AS WSTRINGZ , BYREF username AS WSTRINGZ , BYVAL level AS QUAD , BYREF bufptr AS ANY , BYVAL prefmaxlen AS QUAD , BYREF entriesread AS QUAD , BYREF totalentries AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetUserSetGroups LIB "NetAPI32.dll" ALIAS "NetUserSetGroups" ( servername AS WSTRINGZ, username AS WSTRINGZ, BYVAL level AS QUAD, BYVAL buf AS BYTE PTR, BYVAL num_entries AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetUserSetGroups LIB "netapi32.dll" ALIAS "NetUserSetGroups" ( BYREF servername AS WSTRINGZ , BYREF username AS WSTRINGZ , BYVAL level AS QUAD , BYREF buf AS ANY , BYVAL num_entries AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetUserGetLocalGroups LIB "NetAPI32.dll" ALIAS "NetUserGetLocalGroups" ( servername AS WSTRINGZ, username AS WSTRINGZ, BYVAL level AS QUAD, BYVAL flags AS QUAD, BYVAL bufptr AS BYTE PTR, BYVAL prefmaxlen AS QUAD, entriesread AS QUAD, totalentries AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetUserGetLocalGroups LIB "netapi32.dll" ALIAS "NetUserGetLocalGroups" ( BYREF servername AS WSTRINGZ , BYREF username AS WSTRINGZ , BYVAL level AS QUAD , BYVAL flags AS QUAD , BYREF bufptr AS ANY , BYVAL prefmaxlen AS QUAD , BYREF entriesread AS QUAD , BYREF totalentries AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetUserModalsGet LIB "NetAPI32.dll" ALIAS "NetUserModalsGet" ( servername AS WSTRINGZ, BYVAL level AS QUAD, BYVAL bufptr AS BYTE PTR ) AS QUAD
#ELSE
DECLARE FUNCTION NetUserModalsGet LIB "netapi32.dll" ALIAS "NetUserModalsGet" ( BYREF servername AS WSTRINGZ , BYVAL level AS QUAD , BYREF bufptr AS ANY ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetUserModalsSet LIB "NetAPI32.dll" ALIAS "NetUserModalsSet" ( servername AS WSTRINGZ, BYVAL level AS QUAD, BYVAL buf AS BYTE PTR, parm_err AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetUserModalsSet LIB "netapi32.dll" ALIAS "NetUserModalsSet" ( BYREF servername AS WSTRINGZ , BYVAL level AS QUAD , BYREF buf AS ANY , BYREF parm_err AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
DECLARE FUNCTION NetUserChangePassword LIB "netapi32.dll" ALIAS "NetUserChangePassword" ( BYREF domainname AS WSTRINGZ , BYREF username AS WSTRINGZ , BYREF oldpassword AS WSTRINGZ , BYREF newpassword AS WSTRINGZ ) AS QUAD ' NET_API_STATUS
'//
'// Data Structures - User
'//
' // Size = 4 bytes
TYPE USER_INFO_0 DWORD
 usri0_name AS WSTRINGZ PTR ' LPWSTR usri0_name
END TYPE
' // Size = 32 bytes
TYPE USER_INFO_1 DWORD
 usri1_name AS WSTRINGZ PTR ' LPWSTR usri1_name
 usri1_password AS WSTRINGZ PTR ' LPWSTR usri1_password
 usri1_password_age AS DWORD ' DWORD usri1_password_age
 usri1_priv AS DWORD ' DWORD usri1_priv
 usri1_home_dir AS WSTRINGZ PTR ' LPWSTR usri1_home_dir
 usri1_comment AS WSTRINGZ PTR ' LPWSTR usri1_comment
 usri1_flags AS DWORD ' DWORD usri1_flags
 usri1_script_path AS WSTRINGZ PTR ' LPWSTR usri1_script_path
END TYPE
' // Size = 96 bytes
TYPE USER_INFO_2 DWORD
 usri2_name AS WSTRINGZ PTR ' LPWSTR usri2_name
 usri2_password AS WSTRINGZ PTR ' LPWSTR usri2_password
 usri2_password_age AS DWORD ' DWORD usri2_password_age
 usri2_priv AS DWORD ' DWORD usri2_priv
 usri2_home_dir AS WSTRINGZ PTR ' LPWSTR usri2_home_dir
 usri2_comment AS WSTRINGZ PTR ' LPWSTR usri2_comment
 usri2_flags AS DWORD ' DWORD usri2_flags
 usri2_script_path AS WSTRINGZ PTR ' LPWSTR usri2_script_path
 usri2_auth_flags AS DWORD ' DWORD usri2_auth_flags
 usri2_full_name AS WSTRINGZ PTR ' LPWSTR usri2_full_name
 usri2_usr_comment AS WSTRINGZ PTR ' LPWSTR usri2_usr_comment
 usri2_parms AS WSTRINGZ PTR ' LPWSTR usri2_parms
 usri2_workstations AS WSTRINGZ PTR ' LPWSTR usri2_workstations
 usri2_last_logon AS DWORD ' DWORD usri2_last_logon
 usri2_last_logoff AS DWORD ' DWORD usri2_last_logoff
 usri2_acct_expires AS DWORD ' DWORD usri2_acct_expires
 usri2_max_storage AS DWORD ' DWORD usri2_max_storage
 usri2_units_per_week AS DWORD ' DWORD usri2_units_per_week
 usri2_logon_hours AS BYTE PTR ' PBYTE usri2_logon_hours
 usri2_bad_pw_count AS DWORD ' DWORD usri2_bad_pw_count
 usri2_num_logons AS DWORD ' DWORD usri2_num_logons
 usri2_logon_server AS WSTRINGZ PTR ' LPWSTR usri2_logon_server
 usri2_country_code AS DWORD ' DWORD usri2_country_code
 usri2_code_page AS DWORD ' DWORD usri2_code_page
END TYPE
' // Size = 116 bytes
TYPE USER_INFO_3 DWORD
 usri3_name AS WSTRINGZ PTR ' LPWSTR usri3_name
 usri3_password AS WSTRINGZ PTR ' LPWSTR usri3_password
 usri3_password_age AS DWORD ' DWORD usri3_password_age
 usri3_priv AS DWORD ' DWORD usri3_priv
 usri3_home_dir AS WSTRINGZ PTR ' LPWSTR usri3_home_dir
 usri3_comment AS WSTRINGZ PTR ' LPWSTR usri3_comment
 usri3_flags AS DWORD ' DWORD usri3_flags
 usri3_script_path AS WSTRINGZ PTR ' LPWSTR usri3_script_path
 usri3_auth_flags AS DWORD ' DWORD usri3_auth_flags
 usri3_full_name AS WSTRINGZ PTR ' LPWSTR usri3_full_name
 usri3_usr_comment AS WSTRINGZ PTR ' LPWSTR usri3_usr_comment
 usri3_parms AS WSTRINGZ PTR ' LPWSTR usri3_parms
 usri3_workstations AS WSTRINGZ PTR ' LPWSTR usri3_workstations
 usri3_last_logon AS DWORD ' DWORD usri3_last_logon
 usri3_last_logoff AS DWORD ' DWORD usri3_last_logof
 usri3_acct_expires AS DWORD ' DWORD usri3_acct_expires
 usri3_max_storage AS DWORD ' DWORD usri3_max_storage
 usri3_units_per_week AS DWORD ' DWORD usri3_units_per_week
 usri3_logon_hours AS BYTE PTR ' PBYTE usri3_logon_hours
 usri3_bad_pw_count AS DWORD ' DWORD usri3_bad_pw_count
 usri3_num_logons AS DWORD ' DWORD usri3_num_logons
 usri3_logon_server AS WSTRINGZ PTR ' LPWSTR usri3_logon_server
 usri3_country_code AS DWORD ' DWORD usri3_country_code
 usri3_code_page AS DWORD ' DWORD usri3_code_page
 usri3_user_id AS DWORD ' DWORD usri3_user_id
 usri3_primary_group_id AS DWORD ' DWORD usri3_primary_group_id
 usri3_profile AS WSTRINGZ PTR ' LPWSTR usri3_profile
 usri3_home_dir_drive AS WSTRINGZ PTR ' LPWSTR usri3_home_dir_drive
 usri3_password_expired AS DWORD ' DWORD usri3_password_expired
END TYPE
' // Size = 116 bytes
TYPE USER_INFO_4 DWORD
 usri4_name AS WSTRINGZ PTR ' LPWSTR usri4_name;
 usri4_password AS WSTRINGZ PTR ' LPWSTR usri4_password
 usri4_password_age AS DWORD ' DWORD usri4_password_age
 usri4_priv AS DWORD ' DWORD usri4_priv
 usri4_home_dir AS WSTRINGZ PTR ' LPWSTR usri4_home_dir
 usri4_comment AS WSTRINGZ PTR ' LPWSTR usri4_comment
 usri4_flags AS DWORD ' DWORD usri4_flags
 usri4_script_path AS WSTRINGZ PTR ' LPWSTR usri4_script_path
 usri4_auth_flags AS DWORD ' DWORD usri4_auth_flags
 usri4_full_name AS WSTRINGZ PTR ' LPWSTR usri4_full_name
 usri4_usr_comment AS WSTRINGZ PTR ' LPWSTR usri4_usr_comment
 usri4_parms AS WSTRINGZ PTR ' LPWSTR usri4_parms
 usri4_workstations AS WSTRINGZ PTR ' LPWSTR usri4_workstations
 usri4_last_logon AS DWORD ' DWORD usri4_last_logon
 usri4_last_logoff AS DWORD ' DWORD usri4_last_logoff
 usri4_acct_expires AS DWORD ' DWORD usri4_acct_expires
 usri4_max_storage AS DWORD ' DWORD usri4_max_storage
 usri4_units_per_week AS DWORD ' DWORD usri4_units_per_week
 usri4_logon_hours AS BYTE PTR ' PBYTE usri4_logon_hours
 usri4_bad_pw_count AS DWORD ' DWORD usri4_bad_pw_count
 usri4_num_logons AS DWORD ' DWORD usri4_num_logons
 usri4_logon_server AS WSTRINGZ PTR ' LPWSTR usri4_logon_server
 usri4_country_code AS DWORD ' DWORD usri4_country_code
 usri4_code_page AS DWORD ' DWORD usri4_code_page
 usri4_user_sid AS SID PTR ' PSID usri4_user_sid
 usri4_primary_group_id AS DWORD ' DWORD usri4_primary_group_id
 usri4_profile AS WSTRINGZ PTR ' LPWSTR usri4_profile
 usri4_home_dir_drive AS WSTRINGZ PTR ' LPWSTR usri4_home_dir_drive
 usri4_password_expired AS DWORD ' DWORD usri4_password_expired
END TYPE
' // Size = 16 bytes
TYPE USER_INFO_10 DWORD
 usri10_name AS WSTRINGZ PTR ' LPWSTR usri10_name
 usri10_comment AS WSTRINGZ PTR ' LPWSTR usri10_comment
 usri10_usr_comment AS WSTRINGZ PTR ' LPWSTR usri10_usr_comment
 usri10_full_name AS WSTRINGZ PTR ' LPWSTR usri10_full_name
END TYPE
' // Size = 80 bytes
TYPE USER_INFO_11 DWORD
 usri11_name AS WSTRINGZ PTR ' LPWSTR usri11_name
 usri11_comment AS WSTRINGZ PTR ' LPWSTR usri11_comment
 usri11_usr_comment AS WSTRINGZ PTR ' LPWSTR usri11_usr_comment
 usri11_full_name AS WSTRINGZ PTR ' LPWSTR usri11_full_name
 usri11_priv AS DWORD ' DWORD usri11_priv
 usri11_auth_flags AS DWORD ' DWORD usri11_auth_flags
 usri11_password_age AS DWORD ' DWORD usri11_password_age
 usri11_home_dir AS WSTRINGZ PTR ' LPWSTR usri11_home_dir
 usri11_parms AS WSTRINGZ PTR ' LPWSTR usri11_parms
 usri11_last_logon AS DWORD ' DWORD usri11_last_logon
 usri11_last_logoff AS DWORD ' DWORD usri11_last_logoff
 usri11_bad_pw_count AS DWORD ' DWORD usri11_bad_pw_count
 usri11_num_logons AS DWORD ' DWORD usri11_num_logons
 usri11_logon_server AS WSTRINGZ PTR ' LPWSTR usri11_logon_server
 usri11_country_code AS DWORD ' DWORD usri11_country_code
 usri11_workstations AS WSTRINGZ PTR ' LPWSTR usri11_workstations
 usri11_max_storage AS DWORD ' DWORD usri11_max_storage
 usri11_units_per_week AS DWORD ' DWORD usri11_units_per_week
 usri11_logon_hours AS BYTE PTR ' PBYTE usri11_logon_hours
 usri11_code_page AS DWORD ' DWORD usri11_code_page
END TYPE
' // Size = 20 bytes
TYPE USER_INFO_20 DWORD
 usri20_name AS WSTRINGZ PTR ' LPWSTR usri20_name
 usri20_full_name AS WSTRINGZ PTR ' LPWSTR usri20_full_name
 usri20_comment AS WSTRINGZ PTR ' LPWSTR usri20_comment
 usri20_flags AS DWORD ' DWORD usri20_flags
 usri20_user_id AS DWORD ' DWORD usri20_user_id
END TYPE
' // Size = 16 bytes
TYPE USER_INFO_21 BYTE
 usri21_password AS STRING * %ENCRYPTED_PWLEN ' BYTE usri21_password[ENCRYPTED_PWLEN]
END TYPE
' // Size = 108 bytes
TYPE USER_INFO_22 DWORD
 usri22_name AS WSTRINGZ PTR ' LPWSTR usri22_name
 usri22_password AS STRING * %ENCRYPTED_PWLEN ' BYTE usri22_password[ENCRYPTED_PWLEN]
 usri22_password_age AS DWORD ' DWORD usri22_password_age
 usri22_priv AS DWORD ' DWORD usri22_priv
 usri22_home_dir AS WSTRINGZ PTR ' LPWSTR usri22_home_dir
 usri22_comment AS WSTRINGZ PTR ' LPWSTR usri22_comment
 usri22_flags AS DWORD ' DWORD usri22_flags
 usri22_script_path AS WSTRINGZ PTR ' LPWSTR usri22_script_path
 usri22_auth_flags AS DWORD ' DWORD usri22_auth_flags
 usri22_full_name AS WSTRINGZ PTR ' LPWSTR usri22_full_name
 usri22_usr_comment AS WSTRINGZ PTR ' LPWSTR usri22_usr_comment
 usri22_parms AS WSTRINGZ PTR ' LPWSTR usri22_parms
 usri22_workstations AS WSTRINGZ PTR ' LPWSTR usri22_workstations
 usri22_last_logon AS DWORD ' DWORD usri22_last_logon
 usri22_last_logoff AS DWORD ' DWORD usri22_last_logoff
 usri22_acct_expires AS DWORD ' DWORD usri22_acct_expires
 usri22_max_storage AS DWORD ' DWORD usri22_max_storage
 usri22_units_per_week AS DWORD ' DWORD usri22_units_per_week
 usri22_logon_hours AS BYTE PTR ' PBYTE usri22_logon_hours
 usri22_bad_pw_count AS DWORD ' DWORD usri22_bad_pw_count
 usri22_num_logons AS DWORD ' DWORD usri22_num_logons
 usri22_logon_server AS WSTRINGZ PTR ' LPWSTR usri22_logon_server
 usri22_country_code AS DWORD ' DWORD usri22_country_code
 usri22_code_page AS DWORD ' DWORD usri22_code_page
END TYPE
' // Size = 20 bytes
TYPE USER_INFO_23 DWORD
 usri23_name AS WSTRINGZ PTR ' LPWSTR usri23_name
 usri23_full_name AS WSTRINGZ PTR ' LPWSTR usri23_full_name
 usri23_comment AS WSTRINGZ PTR ' LPWSTR usri23_comment
 usri23_flags AS DWORD ' DWORD usri23_flags
 usri23_user_sid AS SID PTR ' PSID usri23_user_sid
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1003 DWORD
 usri1003_password AS WSTRINGZ PTR ' LPWSTR usri1003_password
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1005 DWORD
 usri1005_priv AS DWORD ' DWORD usri1005_priv
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1006 DWORD
 usri1006_home_dir AS WSTRINGZ PTR ' LPWSTR usri1006_home_dir
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1007 DWORD
 usri1007_comment AS WSTRINGZ PTR ' LPWSTR usri1007_comment
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1008 DWORD
 usri1008_flags AS DWORD ' DWORD usri1008_flags
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1009 DWORD
 usri1009_script_path AS WSTRINGZ PTR ' LPWSTR usri1009_script_path
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1010 DWORD
 usri1010_auth_flags AS DWORD ' DWORD usri1010_auth_flags
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1011 DWORD
 usri1011_full_name AS WSTRINGZ PTR ' LPWSTR usri1011_full_name
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1012 DWORD
 usri1012_usr_comment AS WSTRINGZ PTR ' LPWSTR usri1012_usr_comment
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1013 DWORD
 usri1013_parms AS WSTRINGZ PTR ' LPWSTR usri1013_parms
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1014 DWORD
 usri1014_workstations AS WSTRINGZ PTR ' LPWSTR usri1014_workstations;
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1017 DWORD
 usri1017_acct_expires AS DWORD ' DWORD usri1017_acct_expires
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1018 DWORD
 usri1018_max_storage AS DWORD ' DWORD usri1018_max_storage
END TYPE
' // Size = 8 bytes
TYPE USER_INFO_1020 DWORD
 usri1020_units_per_week AS DWORD ' DWORD usri1020_units_per_week
 usri1020_logon_hours AS BYTE PTR ' LPBYTE usri1020_logon_hours
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1023 DWORD
 usri1023_logon_server AS WSTRINGZ PTR ' LPWSTR usri1023_logon_server
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1024 DWORD
 usri1024_country_code AS DWORD ' DWORD usri1024_country_code
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1025 DWORD
 usri1025_code_page AS DWORD ' DWORD usri1025_code_page
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1051 DWORD
 usri1051_primary_group_id AS DWORD ' DWORD usri1051_primary_group_id
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1052 DWORD
 usri1052_profile AS WSTRINGZ PTR ' LPWSTR usri1052_profile
END TYPE
' // Size = 4 bytes
TYPE USER_INFO_1053 DWORD
 usri1053_home_dir_drive AS WSTRINGZ PTR ' LPWSTR usri1053_home_dir_drive
END TYPE
'//
'// Data Structures - User Modals
'//
' // Size = 20 bytes
TYPE USER_MODALS_INFO_0 DWORD
 usrmod0_min_passwd_len AS DWORD ' DWORD usrmod0_min_passwd_len
 usrmod0_max_passwd_age AS DWORD ' DWORD usrmod0_max_passwd_age
 usrmod0_min_passwd_age AS DWORD ' DWORD usrmod0_min_passwd_age
 usrmod0_force_logoff AS DWORD ' DWORD usrmod0_force_logoff
 usrmod0_password_hist_len AS DWORD ' DWORD usrmod0_password_hist_len
END TYPE
' // Size = 4 bytes
TYPE USER_MODALS_INFO_1 DWORD
 usrmod1_role AS DWORD ' DWORD usrmod1_role
 usrmod1_primary AS WSTRINGZ PTR ' LPWSTR usrmod1_primary
END TYPE
' // Size = 8 bytes
TYPE USER_MODALS_INFO_2 DWORD
 usrmod2_domain_name AS WSTRINGZ PTR ' LPWSTR usrmod2_domain_name
 usrmod2_domain_id AS SID PTR ' PSID usrmod2_domain_id
END TYPE
' // Size = 12 bytes
TYPE USER_MODALS_INFO_3 DWORD
 usrmod3_lockout_duration AS DWORD ' DWORD usrmod3_lockout_duration
 usrmod3_lockout_observation_window AS DWORD ' DWORD usrmod3_lockout_observation_window
 usrmod3_lockout_threshold AS DWORD ' DWORD usrmod3_lockout_threshold
END TYPE
' // Size = 4 bytes
TYPE USER_MODALS_INFO_1001 DWORD
 usrmod1001_min_passwd_len AS DWORD ' DWORD usrmod1001_min_passwd_len
END TYPE
' // Size = 4 bytes
TYPE USER_MODALS_INFO_1002 DWORD
 usrmod1002_max_passwd_age AS DWORD ' DWORD usrmod1002_max_passwd_age
END TYPE
' // Size = 4 bytes
TYPE USER_MODALS_INFO_1003 DWORD
 usrmod1003_min_passwd_age AS DWORD ' DWORD usrmod1003_min_passwd_age
END TYPE
' // Size = 4 bytes
TYPE USER_MODALS_INFO_1004 DWORD
 usrmod1004_force_logoff AS DWORD ' DWORD usrmod1004_force_logoff
END TYPE
' // Size = 4 bytes
TYPE USER_MODALS_INFO_1005 DWORD
 usrmod1005_password_hist_len AS DWORD ' DWORD usrmod1005_password_hist_len
END TYPE
' // Size = 4 bytes
TYPE USER_MODALS_INFO_1006 DWORD
 usrmod1006_role AS DWORD ' DWORD usrmod1006_role
END TYPE
' // Size = 4 bytes
TYPE USER_MODALS_INFO_1007 DWORD
 usrmod1007_primary AS WSTRINGZ PTR ' LPWSTR usrmod1007_primary
END TYPE
'//
'// Special Values and Constants - User
'//
'//
'// Bit masks for field usriX_flags of USER_INFO_X (X = 0/1).
'//
%EQUATE `UF_SCRIPT = &H0001
%EQUATE `UF_ACCOUNTDISABLE = &H0002
%EQUATE `UF_HOMEDIR_REQUIRED = &H0008
%EQUATE `UF_LOCKOUT = &H0010
%EQUATE `UF_PASSWD_NOTREQD = &H0020
%EQUATE `UF_PASSWD_CANT_CHANGE = &H0040
%EQUATE `UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED = &H0080
'//
'// Account type bits as part of usri_flags.
'//
%EQUATE `UF_TEMP_DUPLICATE_ACCOUNT = &H0100
%EQUATE `UF_NORMAL_ACCOUNT = &H0200
%EQUATE `UF_INTERDOMAIN_TRUST_ACCOUNT = &H0800
%EQUATE `UF_WORKSTATION_TRUST_ACCOUNT = &H1000
%EQUATE `UF_SERVER_TRUST_ACCOUNT = &H2000
%EQUATE `UF_MACHINE_ACCOUNT_MASK = %UF_INTERDOMAIN_TRUST_ACCOUNT OR %UF_WORKSTATION_TRUST_ACCOUNT OR %UF_SERVER_TRUST_ACCOUNT
%EQUATE `UF_ACCOUNT_TYPE_MASK = %UF_TEMP_DUPLICATE_ACCOUNT OR %UF_NORMAL_ACCOUNT OR %UF_INTERDOMAIN_TRUST_ACCOUNT OR %UF_WORKSTATION_TRUST_ACCOUNT OR %UF_SERVER_TRUST_ACCOUNT
%EQUATE `UF_DONT_EXPIRE_PASSWD = &H10000
%EQUATE `UF_MNS_LOGON_ACCOUNT = &H20000
%EQUATE `UF_SMARTCARD_REQUIRED = &H40000
%EQUATE `UF_TRUSTED_FOR_DELEGATION = &H80000
%EQUATE `UF_NOT_DELEGATED = &H100000
%EQUATE `UF_USE_DES_KEY_ONLY = &H200000
%EQUATE `UF_DONT_REQUIRE_PREAUTH = &H400000
%EQUATE `UF_PASSWORD_EXPIRED = &H800000
%EQUATE `UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION = &H1000000
%EQUATE `UF_NO_AUTH_DATA_REQUIRED = &H2000000
%EQUATE `UF_PARTIAL_SECRETS_ACCOUNT = &H4000000
%EQUATE `UF_USE_AES_KEYS = &H8000000
%EQUATE `UF_SETTABLE_BITS = %UF_SCRIPT OR %UF_ACCOUNTDISABLE OR %UF_LOCKOUT OR %UF_HOMEDIR_REQUIRED OR %UF_PASSWD_NOTREQD OR %UF_PASSWD_CANT_CHANGE OR %UF_ACCOUNT_TYPE_MASK OR %UF_DONT_EXPIRE_PASSWD OR %UF_MNS_LOGON_ACCOUNT OR %UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED OR %UF_SMARTCARD_REQUIRED OR %UF_TRUSTED_FOR_DELEGATION OR %UF_NOT_DELEGATED OR %UF_USE_DES_KEY_ONLY OR %UF_DONT_REQUIRE_PREAUTH OR %UF_PASSWORD_EXPIRED OR %UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION OR %UF_NO_AUTH_DATA_REQUIRED OR %UF_USE_AES_KEYS OR %UF_PARTIAL_SECRETS_ACCOUNT
'//
'// bit masks for the NetUserEnum filter parameter.
'//
%EQUATE `FILTER_TEMP_DUPLICATE_ACCOUNT = &H0001
%EQUATE `FILTER_NORMAL_ACCOUNT = &H0002
' %FILTER_PROXY_ACCOUNT = &H0004
%EQUATE `FILTER_INTERDOMAIN_TRUST_ACCOUNT = &H0008
%EQUATE `FILTER_WORKSTATION_TRUST_ACCOUNT = &H0010
%EQUATE `FILTER_SERVER_TRUST_ACCOUNT = &H0020
'//
'// bit masks for the NetUserGetLocalGroups flags
'//
%EQUATE `LG_INCLUDE_INDIRECT = &H0001
'//
'// Bit masks for field usri2_auth_flags of USER_INFO_2.
'//
%EQUATE `AF_OP_PRINT = &H1
%EQUATE `AF_OP_COMM = &H2
%EQUATE `AF_OP_SERVER = &H4
%EQUATE `AF_OP_ACCOUNTS = &H8
%EQUATE `AF_SETTABLE_BITS = %AF_OP_PRINT OR %AF_OP_COMM OR %AF_OP_SERVER OR %AF_OP_ACCOUNTS
'//
'// UAS role manifests under NETLOGON
'//
%EQUATE `UAS_ROLE_STANDALONE = 0
%EQUATE `UAS_ROLE_MEMBER = 1
%EQUATE `UAS_ROLE_BACKUP = 2
%EQUATE `UAS_ROLE_PRIMARY = 3
'//
'// Values for ParmError for NetUserSetInfo.
'//
%EQUATE `USER_NAME_PARMNUM = 1
%EQUATE `USER_PASSWORD_PARMNUM = 3
%EQUATE `USER_PASSWORD_AGE_PARMNUM = 4
%EQUATE `USER_PRIV_PARMNUM = 5
%EQUATE `USER_HOME_DIR_PARMNUM = 6
%EQUATE `USER_COMMENT_PARMNUM = 7
%EQUATE `USER_FLAGS_PARMNUM = 8
%EQUATE `USER_SCRIPT_PATH_PARMNUM = 9
%EQUATE `USER_AUTH_FLAGS_PARMNUM = 10
%EQUATE `USER_FULL_NAME_PARMNUM = 11
%EQUATE `USER_USR_COMMENT_PARMNUM = 12
%EQUATE `USER_PARMS_PARMNUM = 13
%EQUATE `USER_WORKSTATIONS_PARMNUM = 14
%EQUATE `USER_LAST_LOGON_PARMNUM = 15
%EQUATE `USER_LAST_LOGOFF_PARMNUM = 16
%EQUATE `USER_ACCT_EXPIRES_PARMNUM = 17
%EQUATE `USER_MAX_STORAGE_PARMNUM = 18
%EQUATE `USER_UNITS_PER_WEEK_PARMNUM = 19
%EQUATE `USER_LOGON_HOURS_PARMNUM = 20
%EQUATE `USER_PAD_PW_COUNT_PARMNUM = 21
%EQUATE `USER_NUM_LOGONS_PARMNUM = 22
%EQUATE `USER_LOGON_SERVER_PARMNUM = 23
%EQUATE `USER_COUNTRY_CODE_PARMNUM = 24
%EQUATE `USER_CODE_PAGE_PARMNUM = 25
%EQUATE `USER_PRIMARY_GROUP_PARMNUM = 51
%EQUATE `USER_PROFILE = 52 ' ?? Delete when convenient
%EQUATE `USER_PROFILE_PARMNUM = 52
%EQUATE `USER_HOME_DIR_DRIVE_PARMNUM = 53
'//
'// the new infolevel counterparts of the old info level + parmnum
'//
%EQUATE `USER_NAME_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_NAME_PARMNUM)
%EQUATE `USER_PASSWORD_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_PASSWORD_PARMNUM)
%EQUATE `USER_PASSWORD_AGE_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_PASSWORD_AGE_PARMNUM)
%EQUATE `USER_PRIV_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_PRIV_PARMNUM)
%EQUATE `USER_HOME_DIR_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_HOME_DIR_PARMNUM)
%EQUATE `USER_COMMENT_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_COMMENT_PARMNUM)
%EQUATE `USER_FLAGS_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_FLAGS_PARMNUM)
%EQUATE `USER_SCRIPT_PATH_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_SCRIPT_PATH_PARMNUM)
%EQUATE `USER_AUTH_FLAGS_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_AUTH_FLAGS_PARMNUM)
%EQUATE `USER_FULL_NAME_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_FULL_NAME_PARMNUM)
%EQUATE `USER_USR_COMMENT_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_USR_COMMENT_PARMNUM)
%EQUATE `USER_PARMS_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_PARMS_PARMNUM)
%EQUATE `USER_WORKSTATIONS_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_WORKSTATIONS_PARMNUM)
%EQUATE `USER_LAST_LOGON_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_LAST_LOGON_PARMNUM)
%EQUATE `USER_LAST_LOGOFF_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_LAST_LOGOFF_PARMNUM)
%EQUATE `USER_ACCT_EXPIRES_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_ACCT_EXPIRES_PARMNUM)
%EQUATE `USER_MAX_STORAGE_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_MAX_STORAGE_PARMNUM)
%EQUATE `USER_UNITS_PER_WEEK_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_UNITS_PER_WEEK_PARMNUM)
%EQUATE `USER_LOGON_HOURS_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_LOGON_HOURS_PARMNUM)
%EQUATE `USER_PAD_PW_COUNT_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_PAD_PW_COUNT_PARMNUM)
%EQUATE `USER_NUM_LOGONS_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_NUM_LOGONS_PARMNUM)
%EQUATE `USER_LOGON_SERVER_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_LOGON_SERVER_PARMNUM)
%EQUATE `USER_COUNTRY_CODE_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_COUNTRY_CODE_PARMNUM)
%EQUATE `USER_CODE_PAGE_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_CODE_PAGE_PARMNUM)
%EQUATE `USER_PRIMARY_GROUP_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_PRIMARY_GROUP_PARMNUM)
' ** Microsoft never defines %USER_POSIX_ID_PARMNUM ...!
'%USER_POSIX_ID_INFOLEVEL = ' (%PARMNUM_BASE_INFOLEVEL + %USER_POSIX_ID_PARMNUM)
%EQUATE `USER_HOME_DIR_DRIVE_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %USER_HOME_DIR_DRIVE_PARMNUM)
'//
'// For SetInfo call (parmnum 0) when password change not required
'//
$NULL_USERSETINFO_PASSWD = " "
%EQUATE `TIMEQ_FOREVER = &HFFFFFFFF ' ((unsigned long) -1L)
%EQUATE `USER_MAXSTORAGE_UNLIMITED = &HFFFFFFFF ' ((unsigned long) -1L)
%EQUATE `USER_NO_LOGOFF = &HFFFFFFFF ' ((unsigned long) -1L)
%EQUATE `UNITS_PER_DAY = 24
%EQUATE `UNITS_PER_WEEK = %UNITS_PER_DAY * 7
'//
'// Privilege levels (USER_INFO_X field usriX_priv (X = 0/1)).
'//
%EQUATE `USER_PRIV_MASK = &H3
%EQUATE `USER_PRIV_GUEST = 0
%EQUATE `USER_PRIV_USER = 1
%EQUATE `USER_PRIV_ADMIN = 2
'//
'// user modals related defaults
'//
%EQUATE `MAX_PASSWD_LEN = %PWLEN
%EQUATE `DEF_MIN_PWLEN = 6
%EQUATE `DEF_PWUNIQUENESS = 5
%EQUATE `DEF_MAX_PWHIST = 8
%EQUATE `DEF_MAX_PWAGE = %TIMEQ_FOREVER ' forever
%EQUATE `DEF_MIN_PWAGE = 0 ' 0 days
%EQUATE `DEF_FORCE_LOGOFF = &HFFFFFFFF ' never
%EQUATE `DEF_MAX_BADPW = 0 ' no limit
%EQUATE `ONE_DAY = 01*24*3600 ' 1 day
'//
'// User Logon Validation (codes returned)
'//
%EQUATE `VALIDATED_LOGON = 0
%EQUATE `PASSWORD_EXPIRED = 2
%EQUATE `NON_VALIDATED_LOGON = 3
%EQUATE `VALID_LOGOFF = 1
'//
'// parmnum manifests for user modals
'//
%EQUATE `MODALS_MIN_PASSWD_LEN_PARMNUM = 1
%EQUATE `MODALS_MAX_PASSWD_AGE_PARMNUM = 2
%EQUATE `MODALS_MIN_PASSWD_AGE_PARMNUM = 3
%EQUATE `MODALS_FORCE_LOGOFF_PARMNUM = 4
%EQUATE `MODALS_PASSWD_HIST_LEN_PARMNUM = 5
%EQUATE `MODALS_ROLE_PARMNUM = 6
%EQUATE `MODALS_PRIMARY_PARMNUM = 7
%EQUATE `MODALS_DOMAIN_NAME_PARMNUM = 8
%EQUATE `MODALS_DOMAIN_ID_PARMNUM = 9
%EQUATE `MODALS_LOCKOUT_DURATION_PARMNUM = 10
%EQUATE `MODALS_LOCKOUT_OBSERVATION_WINDOW_PARMNUM = 11
%EQUATE `MODALS_LOCKOUT_THRESHOLD_PARMNUM = 12
'//
'// the new infolevel counterparts of the old info level + parmnum
'//
%EQUATE `MODALS_MIN_PASSWD_LEN_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %MODALS_MIN_PASSWD_LEN_PARMNUM)
%EQUATE `MODALS_MAX_PASSWD_AGE_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %MODALS_MAX_PASSWD_AGE_PARMNUM)
%EQUATE `MODALS_MIN_PASSWD_AGE_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %MODALS_MIN_PASSWD_AGE_PARMNUM)
%EQUATE `MODALS_FORCE_LOGOFF_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %MODALS_FORCE_LOGOFF_PARMNUM)
%EQUATE `MODALS_PASSWD_HIST_LEN_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %MODALS_PASSWD_HIST_LEN_PARMNUM)
%EQUATE `MODALS_ROLE_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %MODALS_ROLE_PARMNUM)
%EQUATE `MODALS_PRIMARY_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %MODALS_PRIMARY_PARMNUM)
%EQUATE `MODALS_DOMAIN_NAME_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %MODALS_DOMAIN_NAME_PARMNUM)
%EQUATE `MODALS_DOMAIN_ID_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %MODALS_DOMAIN_ID_PARMNUM)
'#endif // _LMUSER_
#ENDIF ' #IF NOT %DEF(%LMUSER)
'//
'// Group Class
'//
#IF NOT %DEF(%LMGROUP)
 %LMGROUP = 1
'//
'// Function Prototypes
'//
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetGroupAdd LIB "NetAPI32.dll" ALIAS "NetGroupAdd" ( servername AS WSTRINGZ, BYVAL level AS QUAD, BYVAL buf AS BYTE PTR, parm_err AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetGroupAdd LIB "netapi32.dll" ALIAS "NetGroupAdd" ( BYREF servername AS WSTRINGZ , BYVAL level AS QUAD , BYREF buf AS ANY , BYREF parm_err AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
DECLARE FUNCTION NetGroupAddUser LIB "netapi32.dll" ALIAS "NetGroupAddUser" ( BYREF servername AS WSTRINGZ , BYREF GroupName AS WSTRINGZ , BYREF username AS WSTRINGZ ) AS QUAD ' NET_API_STATUS
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetGroupEnum LIB "NetAPI32.dll" ALIAS "NetGroupEnum" ( servername AS WSTRINGZ, BYVAL level AS QUAD, BYVAL bufptr AS BYTE PTR, BYVAL prefmaxlen AS QUAD, entriesread AS QUAD, totalentries AS QUAD, resume_handle AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetGroupEnum LIB "netapi32.dll" ALIAS "NetGroupEnum" ( BYREF servername AS WSTRINGZ , BYVAL level AS QUAD , BYREF bufptr AS ANY , BYVAL prefmaxlen AS QUAD , BYREF entriesread AS QUAD , BYREF totalentries AS QUAD , BYREF resume_handle AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetGroupGetInfo LIB "NetAPI32.dll" ALIAS "NetGroupGetInfo" ( servername AS WSTRINGZ, GroupName AS WSTRINGZ, BYVAL level AS QUAD, BYVAL bufptr AS BYTE PTR ) AS QUAD
#ELSE
DECLARE FUNCTION NetGroupGetInfo LIB "netapi32.dll" ALIAS "NetGroupGetInfo" ( BYREF servername AS WSTRINGZ , BYREF groupname AS WSTRINGZ , BYVAL level AS QUAD , BYREF bufptr AS ANY ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetGroupSetInfo LIB "NetAPI32.dll" ALIAS "NetGroupSetInfo" ( servername AS WSTRINGZ, GroupName AS WSTRINGZ, BYVAL level AS QUAD, BYVAL buf AS BYTE PTR, parm_err AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetGroupSetInfo LIB "netapi32.dll" ALIAS "NetGroupSetInfo" ( BYREF servername AS WSTRINGZ , BYREF groupname AS WSTRINGZ , BYVAL level AS QUAD , BYREF buf AS ANY , BYREF parm_err AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
DECLARE FUNCTION NetGroupDel LIB "netapi32.dll" ALIAS "NetGroupDel" ( BYREF servername AS WSTRINGZ , BYREF groupname AS WSTRINGZ ) AS QUAD ' NET_API_STATUS
DECLARE FUNCTION NetGroupDelUser LIB "netapi32.dll" ALIAS "NetGroupDelUser" ( BYREF servername AS WSTRINGZ , BYREF GroupName AS WSTRINGZ , BYREF Username AS WSTRINGZ ) AS QUAD ' NET_API_STATUS
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetGroupGetUsers LIB "NetAPI32.dll" ALIAS "NetGroupGetUsers" ( servername AS WSTRINGZ, GroupName AS WSTRINGZ, BYVAL level AS QUAD, BYVAL bufptr AS BYTE PTR, BYVAL prefmaxlen AS QUAD, entriesread AS QUAD, totalentries AS QUAD, resume_handle AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetGroupGetUsers LIB "netapi32.dll" ALIAS "NetGroupGetUsers" ( BYREF servername AS WSTRINGZ , BYREF groupname AS WSTRINGZ , BYVAL level AS QUAD , BYREF bufptr AS ANY , BYVAL prefmaxlen AS QUAD , BYREF entriesread AS QUAD , BYREF totalentries AS QUAD , BYREF ResumeHandle AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetGroupSetUsers LIB "NetAPI32.dll" ALIAS "NetGroupSetUsers" ( servername AS WSTRINGZ, GroupName AS WSTRINGZ, BYVAL level AS QUAD, BYVAL buf AS BYTE PTR, BYVAL totalentries AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetGroupSetUsers LIB "netapi32.dll" ALIAS "NetGroupSetUsers" ( BYREF servername AS WSTRINGZ , BYREF groupname AS WSTRINGZ , BYVAL level AS QUAD , BYREF buf AS ANY , BYVAL totalentries AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
'//
'// Data Structures - Group
'//
' // Size = 4 bytes
TYPE GROUP_INFO_0 DWORD
 grpi0_name AS WSTRINGZ PTR ' LPWSTR grpi0_name
END TYPE
' // Size = 8 bytes
TYPE GROUP_INFO_1 DWORD
 grpi1_name AS WSTRINGZ PTR ' LPWSTR grpi1_name
 grpi1_comment AS WSTRINGZ PTR ' LPWSTR grpi1_comment
END TYPE
' // Size = 16 bytes
TYPE GROUP_INFO_2 DWORD
 grpi2_name AS WSTRINGZ PTR ' LPWSTR grpi2_name
 grpi2_comment AS WSTRINGZ PTR ' LPWSTR grpi2_comment
 grpi2_group_id AS DWORD ' DWORD grpi2_group_id
 grpi2_attributes AS DWORD ' DWORD grpi2_attributes
END TYPE
' // Size = 16 bytes
TYPE GROUP_INFO_3 DWORD
 grpi3_name AS WSTRINGZ PTR ' LPWSTR grpi3_name
 grpi3_comment AS WSTRINGZ PTR ' LPWSTR grpi3_comment
 grpi3_group_sid AS SID PTR ' PSID grpi3_group_sid
 grpi3_attributes AS DWORD ' DWORD grpi3_attributes
END TYPE
' // Size = 4 bytes
TYPE GROUP_INFO_1002 DWORD
 grpi1002_comment AS WSTRINGZ PTR ' LPWSTR grpi1002_comment
END TYPE
' // Size = 4 bytes
TYPE GROUP_INFO_1005 DWORD
 grpi1005_attributes AS DWORD ' DWORD grpi1005_attributes
END TYPE
' // Size = 4 bytes
TYPE GROUP_USERS_INFO_0 DWORD
 grui0_name AS WSTRINGZ PTR ' LPWSTR grui0_name
END TYPE
' // Size = 8 bytes
TYPE GROUP_USERS_INFO_1 DWORD
 grui1_name AS WSTRINGZ PTR ' LPWSTR grui1_name
 grui1_attributes AS DWORD ' DWORD grui1_attributes
END TYPE
'//
'// Special Values and Constants - Group
'//
%EQUATE `GROUPIDMASK = &H8000 ' MSB set if uid refers to a group
'//
'// Predefined group for all normal users, administrators and guests
'// LOCAL is a special group for pinball local security.
'//
'#define GROUP_SPECIALGRP_USERS L"USERS"
'#define GROUP_SPECIALGRP_ADMINS L"ADMINS"
'#define GROUP_SPECIALGRP_GUESTS L"GUESTS"
'#define GROUP_SPECIALGRP_LOCAL L"LOCAL"
$$GROUP_SPECIALGRP_USERS = "USERS"$$
$$GROUP_SPECIALGRP_ADMINS = "ADMINS"$$
$$GROUP_SPECIALGRP_GUESTS = "GUESTS"$$
$$GROUP_SPECIALGRP_LOCAL = "LOCAL"$$
'//
'// parmnum manifests for SetInfo calls (only comment is settable)
'//
%EQUATE `GROUP_ALL_PARMNUM = 0
%EQUATE `GROUP_NAME_PARMNUM = 1
%EQUATE `GROUP_COMMENT_PARMNUM = 2
%EQUATE `GROUP_ATTRIBUTES_PARMNUM = 3
'//
'// the new infolevel counterparts of the old info level + parmnum
'//
%EQUATE `GROUP_ALL_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %GROUP_ALL_PARMNUM)
%EQUATE `GROUP_NAME_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %GROUP_NAME_PARMNUM)
%EQUATE `GROUP_COMMENT_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %GROUP_COMMENT_PARMNUM)
%EQUATE `GROUP_ATTRIBUTES_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %GROUP_ATTRIBUTES_PARMNUM)
' ** Microsoft never defines %GROUP_POSIX_ID_PARMNUM ...!
'%GROUP_POSIX_ID_INFOLEVEL = ' (%PARMNUM_BASE_INFOLEVEL + %GROUP_POSIX_ID_PARMNUM)
'#endif // _LMGROUP_
#ENDIF ' #IF NOT %DEF(%LMGROUP)
'//
'// LocalGroup Class
'//
#IF NOT %DEF(%LMLOCALGROUP)
 %LMLOCALGROUP = 1
'//
'// Function Prototypes
'//
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetLocalGroupAdd LIB "NetAPI32.dll" ALIAS "NetLocalGroupAdd" ( servername AS WSTRINGZ, BYVAL level AS QUAD, BYVAL buf AS BYTE PTR, parm_err AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetLocalGroupAdd LIB "netapi32.dll" ALIAS "NetLocalGroupAdd" ( BYREF servername AS WSTRINGZ , BYVAL level AS QUAD , BYREF buf AS ANY , BYREF parm_err AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetLocalGroupAddMember LIB "NetAPI32.dll" ALIAS "NetLocalGroupAddMember" ( servername AS WSTRINGZ, GroupName AS WSTRINGZ, membersid AS SID ) AS QUAD
#ELSE
DECLARE FUNCTION NetLocalGroupAddMember LIB "netapi32.dll" ALIAS "NetLocalGroupAddMember" ( BYREF servername AS WSTRINGZ , BYREF groupname AS WSTRINGZ , BYVAL membersid AS SID PTR ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetLocalGroupEnum LIB "NetAPI32.dll" ALIAS "NetLocalGroupEnum" ( servername AS WSTRINGZ, BYVAL level AS QUAD, BYVAL bufptr AS BYTE PTR, BYVAL prefmaxlen AS QUAD, entriesread AS QUAD, totalentries AS QUAD, resumehandle AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetLocalGroupEnum LIB "netapi32.dll" ALIAS "NetLocalGroupEnum" ( BYREF servername AS WSTRINGZ , BYVAL level AS QUAD , BYREF bufptr AS ANY , BYVAL prefmaxlen AS QUAD , BYREF entriesread AS QUAD , BYREF totalentries AS QUAD , BYREF resumehandle AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetLocalGroupGetInfo LIB "NetAPI32.dll" ALIAS "NetLocalGroupGetInfo" ( servername AS WSTRINGZ, GroupName AS WSTRINGZ, BYVAL level AS QUAD, BYVAL bufptr AS BYTE PTR ) AS QUAD
#ELSE
DECLARE FUNCTION NetLocalGroupGetInfo LIB "netapi32.dll" ALIAS "NetLocalGroupGetInfo" ( BYREF servername AS WSTRINGZ , BYREF groupname AS WSTRINGZ , BYVAL level AS QUAD , BYREF bufptr AS ANY ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetLocalGroupSetInfo LIB "NetAPI32.dll" ALIAS "NetLocalGroupSetInfo" ( servername AS WSTRINGZ, GroupName AS WSTRINGZ, BYVAL level AS QUAD, BYVAL buf AS BYTE PTR, parm_err AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetLocalGroupSetInfo LIB "netapi32.dll" ALIAS "NetLocalGroupSetInfo" ( BYREF servername AS WSTRINGZ , BYREF groupname AS WSTRINGZ , BYVAL level AS QUAD , BYREF buf AS ANY , BYREF parm_err AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
DECLARE FUNCTION NetLocalGroupDel LIB "netapi32.dll" ALIAS "NetLocalGroupDel" ( BYREF servername AS WSTRINGZ , BYREF groupname AS WSTRINGZ ) AS QUAD ' NET_API_STATUS
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetLocalGroupDelMember LIB "NetAPI32.dll" ALIAS "NetLocalGroupDelMember" ( servername AS WSTRINGZ, GroupName AS WSTRINGZ, membersid AS SID ) AS QUAD
#ELSE
DECLARE FUNCTION NetLocalGroupDelMember LIB "netapi32.dll" ALIAS "NetLocalGroupDelMember" ( BYREF servername AS WSTRINGZ , BYREF groupname AS WSTRINGZ , BYVAL membersid AS SID PTR ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetLocalGroupGetMembers LIB "NetAPI32.dll" ALIAS "NetLocalGroupGetMembers" ( servername AS WSTRINGZ, GroupName AS WSTRINGZ, BYVAL level AS QUAD, BYVAL bufptr AS BYTE PTR, BYVAL prefmaxlen AS QUAD, entriesread AS QUAD, totalentries AS QUAD, resumehandle AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetLocalGroupGetMembers LIB "netapi32.dll" ALIAS "NetLocalGroupGetMembers" ( BYREF servername AS WSTRINGZ , BYREF localgroupname AS WSTRINGZ , BYVAL level AS QUAD , BYREF bufptr AS ANY , BYVAL prefmaxlen AS QUAD , BYREF entriesread AS QUAD , BYREF totalentries AS QUAD , BYREF resumehandle AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetLocalGroupSetMembers LIB "NetAPI32.dll" ALIAS "NetLocalGroupSetMembers" ( servername AS WSTRINGZ, GroupName AS WSTRINGZ, BYVAL level AS QUAD, BYVAL buf AS BYTE PTR, BYVAL totalentries AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetLocalGroupSetMembers LIB "netapi32.dll" ALIAS "NetLocalGroupSetMembers" ( BYREF servername AS WSTRINGZ , BYREF groupname AS WSTRINGZ , BYVAL level AS QUAD , BYREF buf AS ANY , BYVAL totalentries AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetLocalGroupAddMembers LIB "NetAPI32.dll" ALIAS "NetLocalGroupAddMembers" ( servername AS WSTRINGZ, GroupName AS WSTRINGZ, BYVAL level AS QUAD, BYVAL buf AS BYTE PTR, BYVAL totalentries AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetLocalGroupAddMembers LIB "netapi32.dll" ALIAS "NetLocalGroupAddMembers" ( BYREF servername AS WSTRINGZ , BYREF groupname AS WSTRINGZ , BYVAL level AS QUAD , BYREF buf AS ANY , BYVAL totalentries AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetLocalGroupDelMembers LIB "NetAPI32.dll" ALIAS "NetLocalGroupDelMembers" ( servername AS WSTRINGZ, GroupName AS WSTRINGZ, BYVAL level AS QUAD, BYVAL buf AS BYTE PTR, BYVAL totalentries AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetLocalGroupDelMembers LIB "netapi32.dll" ALIAS "NetLocalGroupDelMembers" ( BYREF servername AS WSTRINGZ , BYREF groupname AS WSTRINGZ , BYVAL level AS QUAD , BYREF buf AS ANY , BYVAL totalentries AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
'//
'// Data Structures - LocalGroup
'//
' // Size = 4 bytes
TYPE LOCALGROUP_INFO_0 DWORD
 lgrpi0_name AS WSTRINGZ PTR ' LPWSTR lgrpi0_name
END TYPE
' // Size = 8 bytes
TYPE LOCALGROUP_INFO_1 DWORD
 lgrpi1_name AS WSTRINGZ PTR ' LPWSTR lgrpi1_name
 lgrpi1_comment AS WSTRINGZ PTR ' LPWSTR lgrpi1_comment
END TYPE
' // Size = 4 bytes
TYPE LOCALGROUP_INFO_1002 DWORD
 lgrpi1002_comment AS WSTRINGZ PTR ' LPWSTR lgrpi1002_comment
END TYPE
' // Size = 4 bytes
TYPE LOCALGROUP_MEMBERS_INFO_0 DWORD
 lgrmi0_sid AS SID PTR ' PSID lgrmi0_sid
END TYPE
' // Size = 12 bytes
TYPE LOCALGROUP_MEMBERS_INFO_1 DWORD
 lgrmi1_sid AS SID PTR ' PSID lgrmi1_sid
 lgrmi1_sidusage AS LONG ' SID_NAME_USE lgrmi1_sidusage
 lgrmi1_name AS WSTRINGZ PTR ' LPWSTR lgrmi1_name
END TYPE
' // Size = 12 bytes
TYPE LOCALGROUP_MEMBERS_INFO_2 DWORD
 lgrmi2_sid AS SID PTR ' PSID lgrmi2_sid
 lgrmi2_sidusage AS LONG ' SID_NAME_USE lgrmi2_sidusage
 lgrmi2_domainandname AS WSTRINGZ PTR ' LPWSTR lgrmi2_domainandname
END TYPE
' // Size = 4 bytes
TYPE LOCALGROUP_MEMBERS_INFO_3 DWORD
 lgrmi3_domainandname AS WSTRINGZ PTR ' LPWSTR lgrmi3_domainandname
END TYPE
' // Size = 4 bytes
TYPE LOCALGROUP_USERS_INFO_0 DWORD
 lgrui0_name AS WSTRINGZ PTR ' LPWSTR lgrui0_name
END TYPE
%EQUATE `LOCALGROUP_NAME_PARMNUM = 1
%EQUATE `LOCALGROUP_COMMENT_PARMNUM = 2
'//
'// Display Information APIs
'//
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetQueryDisplayInformation LIB "NetAPI32.dll" ALIAS "NetQueryDisplayInformation" ( ServerName AS WSTRINGZ, BYVAL Level AS QUAD, BYVAL Index AS QUAD, BYVAL EntriesRequested AS QUAD, BYVAL PreferredMaximumLength AS QUAD, ReturnedEntryCount AS QUAD, SortedBuffer AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetQueryDisplayInformation LIB "netapi32.dll" ALIAS "NetQueryDisplayInformation" ( BYREF ServerName AS WSTRINGZ , BYVAL Level AS QUAD , BYVAL Index AS QUAD , BYVAL EntriesRequested AS QUAD , BYVAL PreferredMaximumLength AS QUAD , BYREF ReturnedEntryCount AS QUAD , BYREF SortedBuffer AS ANY ) AS QUAD ' NET_API_STATUS
#ENDIF
DECLARE FUNCTION NetGetDisplayInformationIndex LIB "netapi32.dll" ALIAS "NetGetDisplayInformationIndex" ( BYREF ServerName AS WSTRINGZ , BYVAL Level AS QUAD , BYREF Prefix AS WSTRINGZ , BYREF Index AS QUAD ) AS QUAD ' NET_API_STATUS
'//
'// QueryDisplayInformation levels
' // Size = 24 bytes
TYPE NET_DISPLAY_USER DWORD
 usri1_name AS WSTRINGZ PTR ' LPWSTR usri1_name
 usri1_comment AS WSTRINGZ PTR ' LPWSTR usri1_comment
 usri1_flags AS DWORD ' DWORD usri1_flags
 usri1_full_name AS WSTRINGZ PTR ' LPWSTR usri1_full_name
 usri1_user_id AS DWORD ' DWORD usri1_user_id
 usri1_next_index AS DWORD ' DWORD usri1_next_index
END TYPE
' // Size = 20 bytes
TYPE NET_DISPLAY_MACHINE DWORD
 usri2_name AS WSTRINGZ PTR ' LPWSTR usri2_name
 usri2_comment AS WSTRINGZ PTR ' LPWSTR usri2_comment
 usri2_flags AS DWORD ' DWORD usri2_flags
 usri2_user_id AS DWORD ' DWORD usri2_user_id
 usri2_next_index AS DWORD ' DWORD usri2_next_index
END TYPE
' // Size = 20 bytes
TYPE NET_DISPLAY_GROUP DWORD
 grpi3_name AS WSTRINGZ PTR ' LPWSTR grpi3_name
 grpi3_comment AS WSTRINGZ PTR ' LPWSTR grpi3_comment
 grpi3_group_id AS DWORD ' DWORD grpi3_group_id
 grpi3_attributes AS DWORD ' DWORD grpi3_attributes
 grpi3_next_index AS DWORD ' DWORD grpi3_next_index
END TYPE
'#endif // _LMLOCALGROUP_
#ENDIF ' #IF NOT %DEF(%LMLOCALGROUP)
'//
'// Access Class
'//
#IF NOT %DEF(%LMACCESS)
 %LMACCESS = 1
'//
'// Function Prototypes - Access
'//
' This function is obsolete. For a list of alternate functions, see Authorization Functions.
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetAccessAdd LIB "NetAPI32.dll" ALIAS "NetAccessAdd" ( servername AS WSTRINGZ, BYVAL level AS QUAD, BYVAL buf AS BYTE PTR, parm_err AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetAccessAdd LIB "netapi32.dll" ALIAS "RxNetAccessAdd" ( BYREF servername AS WSTRINGZ , BYVAL level AS QUAD , BYREF buf AS ANY , BYREF parm_err AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
'This function is obsolete. For a list of alternate functions, see Authorization Functions.
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetAccessEnum LIB "NetAPI32.dll" ALIAS "NetAccessEnum" ( servername AS WSTRINGZ, BasePath AS WSTRINGZ, BYVAL Recursive AS QUAD, BYVAL level AS QUAD, bufptr AS QUAD, BYVAL prefmaxlen AS QUAD, entriesread AS QUAD, totalentries AS QUAD, resume_handle AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetAccessEnum LIB "netapi32.dll" ALIAS "RxNetAccessEnum" ( BYREF servername AS WSTRINGZ , BYREF BasePath AS WSTRINGZ , BYVAL Recursive AS QUAD , BYVAL level AS QUAD , BYREF bufptr AS ANY , BYVAL prefmaxlen AS QUAD , BYREF entriesread AS QUAD , BYREF totalentries AS QUAD , BYREF resume_handle AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
'This function is obsolete. For a list of alternate functions, see Authorization Functions.
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetAccessGetInfo LIB "NetAPI32.dll" ALIAS "NetAccessGetInfo" ( servername AS WSTRINGZ, resource AS WSTRINGZ, BYVAL level AS QUAD, BYVAL bufptr AS BYTE PTR ) AS QUAD
#ELSE
DECLARE FUNCTION NetAccessGetInfo LIB "netapi32.dll" ALIAS "RxNetAccessGetInfo" ( BYREF servername AS WSTRINGZ , BYREF resource AS WSTRINGZ , BYVAL level AS QUAD , BYREF bufptr AS ANY ) AS QUAD ' NET_API_STATUS
#ENDIF
'This function is obsolete. For a list of alternate functions, see Authorization Functions.
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetAccessSetInfo LIB "NetAPI32.dll" ALIAS "NetAccessSetInfo" ( servername AS WSTRINGZ, resource AS WSTRINGZ, BYVAL level AS QUAD, BYVAL buf AS BYTE PTR, parm_err AS QUAD ) AS QUAD
#ELSE
DECLARE FUNCTION NetAccessSetInfo LIB "netapi32.dll" ALIAS "RxNetAccessSetInfo" ( BYREF servername AS WSTRINGZ , BYREF resource AS WSTRINGZ , BYVAL level AS QUAD , BYREF buf AS ANY , BYREF parm_err AS QUAD ) AS QUAD ' NET_API_STATUS
#ENDIF
'This function is obsolete. For a list of alternate functions, see Authorization Functions.
DECLARE FUNCTION NetAccessDel LIB "netapi32.dll" ALIAS "RxNetAccessDel" ( BYREF servername AS WSTRINGZ , BYREF resource AS WSTRINGZ ) AS QUAD ' NET_API_STATUS
'This function is obsolete. For a list of alternate functions, see Authorization Functions.
DECLARE FUNCTION NetAccessGetUserPerms LIB "netapi32.dll" ALIAS "RxNetAccessGetUserPerms" ( BYREF servername AS WSTRINGZ , BYREF UGname AS WSTRINGZ , BYREF resource AS WSTRINGZ , BYREF Perms AS QUAD ) AS QUAD ' NET_API_STATUS
'//
'// Data Structures - Access
'//
' // Size = 4 bytes
TYPE ACCESS_INFO_0 DWORD
 acc0_resource_name AS WSTRINGZ PTR ' LPWSTR acc0_resource_name
END TYPE
' // Size = 12 bytes
TYPE ACCESS_INFO_1 DWORD
 acc1_resource_name AS WSTRINGZ PTR ' LPWSTR acc1_resource_name
 acc1_attr AS DWORD ' DWORD acc1_attr
 acc1_count AS DWORD ' DWORD acc1_count
END TYPE
' // Size = 4 bytes
TYPE ACCESS_INFO_1002 DWORD
 acc1002_attr AS DWORD ' DWORD acc1002_attr
END TYPE
' // Size = 8 bytes
TYPE ACCESS_LIST DWORD
 acl_ugname AS WSTRINGZ PTR ' LPWSTR acl_ugname
 acl_access AS DWORD ' DWORD acl_access
END TYPE
'//
'// Special Values and Constants - Access
'//
'//
'// Maximum number of permission entries for each resource.
'//
'#define MAXPERMENTRIES 64
%EQUATE `MAXPERMENTRIES = 64
'//
'// Bit values for the access permissions. ACCESS_ALL is a handy
'// way to specify maximum permissions. These are used in
'// acl_access field of access_list structures.
'//
%EQUATE `ACCESS_NONE = 0
%EQUATE `ACCESS_READ = &H01
%EQUATE `ACCESS_WRITE = &H02
%EQUATE `ACCESS_CREATE = &H04
%EQUATE `ACCESS_EXEC = &H08
%EQUATE `ACCESS_DELETE = &H10
%EQUATE `ACCESS_ATRIB = &H20
%EQUATE `ACCESS_PERM = &H40
%EQUATE `ACCESS_ALL = %ACCESS_READ OR %ACCESS_WRITE OR %ACCESS_CREATE OR %ACCESS_EXEC OR %ACCESS_DELETE OR %ACCESS_ATRIB OR %ACCESS_PERM
%EQUATE `ACCESS_GROUP = &H8000
'//
'// Bit values for the acc1_attr field of the ACCESS_INFO_1 structure.
'//
%EQUATE `ACCESS_AUDIT = &H1
%EQUATE `ACCESS_SUCCESS_OPEN = &H10
%EQUATE `ACCESS_SUCCESS_WRITE = &H20
%EQUATE `ACCESS_SUCCESS_DELETE = &H40
%EQUATE `ACCESS_SUCCESS_ACL = &H80
%EQUATE `ACCESS_SUCCESS_MASK = &HF0
%EQUATE `ACCESS_FAIL_OPEN = &H100
%EQUATE `ACCESS_FAIL_WRITE = &H200
%EQUATE `ACCESS_FAIL_DELETE = &H400
%EQUATE `ACCESS_FAIL_ACL = &H800
%EQUATE `ACCESS_FAIL_MASK = &HF00
%EQUATE `ACCESS_FAIL_SHIFT = 4
'//
'// Parmnum value for NetAccessSetInfo.
'//
%EQUATE `ACCESS_RESOURCE_NAME_PARMNUM = 1
%EQUATE `ACCESS_ATTR_PARMNUM = 2
%EQUATE `ACCESS_COUNT_PARMNUM = 3
%EQUATE `ACCESS_ACCESS_LIST_PARMNUM = 4
'//
'// the new infolevel counterparts of the old info level + parmnum
'//
%EQUATE `ACCESS_RESOURCE_NAME_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %ACCESS_RESOURCE_NAME_PARMNUM)
%EQUATE `ACCESS_ATTR_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %ACCESS_ATTR_PARMNUM)
%EQUATE `ACCESS_COUNT_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %ACCESS_COUNT_PARMNUM)
%EQUATE `ACCESS_ACCESS_LIST_INFOLEVEL = (%PARMNUM_BASE_INFOLEVEL + %ACCESS_ACCESS_LIST_PARMNUM)
'//
'// ACCESS_LETTERS defines a letter for each bit position in
'// the acl_access field of struct access_list. Note that some
'// bits have a corresponding letter of ' ' (space).
'//
'#define ACCESS_LETTERS "RWCXDAP "
$ACCESS_LETTERS = "RWCXDAP "
'// ********************************
'//
'// Password Checking API structures
'//
'// ********************************
'//
'// What kind of password checking is to be performed?
'// NetValidateAuthentication : Check if the authentication can be done
'// NetValidatePasswordChange: Check if the password can be changed
'// NetValidatePasswordReset: Reset the password to the given value
'//
' NET_VALIDATE_PASSWORD_TYPE enum
%EQUATE `NetValidateAuthentication = 1
%EQUATE `NetValidatePasswordChange = 2
%EQUATE `NetValidatePasswordReset = 3
'//
'// Structure to keep the password hash
'//
' // Size = 8 bytes
TYPE NET_VALIDATE_PASSWORD_HASH DWORD
 Length AS DWORD ' ULONG Length
 Hash AS BYTE PTR ' LPBYTE Hash
END TYPE
'// To be used with PresentFields member of NET_VALIDATE_PERSISTED_FIELDS
%EQUATE `NET_VALIDATE_PASSWORD_LAST_SET = &H00000001
%EQUATE `NET_VALIDATE_BAD_PASSWORD_TIME = &H00000002
%EQUATE `NET_VALIDATE_LOCKOUT_TIME = &H00000004
%EQUATE `NET_VALIDATE_BAD_PASSWORD_COUNT = &H00000008
%EQUATE `NET_VALIDATE_PASSWORD_HISTORY_LENGTH = &H00000010
%EQUATE `NET_VALIDATE_PASSWORD_HISTORY = &H00000020
'#if !defined(_WINBASE_) && !defined(_FILETIME_)
#IF NOT %DEF(%FILETIME_DEFINED)
%EQUATE `FILETIME_DEFINED = 1
' // Size = 8 bytes
TYPE FILETIME_STRUCT DWORD
 dwLowDateTime AS DWORD
 dwHighDateTime AS DWORD
END TYPE
' // To allow to use both DWORD's and a QUAD
' // Size = 8 bytes
UNION FILETIME DWORD
 FILETIME_STRUCT
 qDateTime AS QUAD
END UNION
#ENDIF
'#endif
'//
'// Structure to keep information about the password and related things.
'// Present Fields: (used only in output args) which fields are changed.
'// See the constants above.
'// PasswordLastSet: When the password is last set.
'// BadPasswordTime: When the password was incorrect for the last time.
'// LockoutTime: When the account is locked out. If the account is not locked out
'// it is 0.
'// BadPasswordCount: How many times the password has given incorrectly in the
'// Observation Window.
'// PasswordHistoryLength: How many passwords are kept in the history
'// PasswordHistory: Password hashes that are in the history
'//
' // Size = 40 bytes
TYPE NET_VALIDATE_PERSISTED_FIELDS DWORD
 PresentFields AS DWORD ' ULONG PresentFields
 PasswordLastSet AS FILETIME ' FILETIME PasswordLastSet
 BadPasswordTime AS FILETIME ' FILETIME BadPasswordTime
 LockoutTime AS FILETIME ' FILETIME LockoutTime
 BadPasswordCount AS DWORD ' ULONG BadPasswordCount
 PasswordHistoryLength AS DWORD ' ULONG PasswordHistoryLength
 PasswordHistory AS NET_VALIDATE_PASSWORD_HASH PTR ' PNET_VALIDATE_PASSWORD_HASH PasswordHistory
END TYPE
'//
'// Output Arg
'// ChangedPersistedFields: Any changes to the password related info
'// ValidationStatus: Shows the result of the request
'//
' // Size = 44 bytes
TYPE NET_VALIDATE_OUTPUT_ARG DWORD
 ChangedPersistedFields AS NET_VALIDATE_PERSISTED_FIELDS ' NET_VALIDATE_PERSISTED_FIELDS ChangedPersistedFields
 ValidationStatus AS DWORD ' NET_API_STATUS ValidationStatus
END TYPE
'//
'// If authentication type of password check is to be made,
'// this kind of input must be used
'//
'// InputPersistedFields: Information about the account to be logged into
'// PasswordMatched: Indicates the result of the application's authentication of the supplied password
'//
' // Size = 44 bytes
TYPE NET_VALIDATE_AUTHENTICATION_INPUT_ARG DWORD
 InputPersistedFields AS NET_VALIDATE_PERSISTED_FIELDS ' NET_VALIDATE_PERSISTED_FIELDS InputPersistedFields
 PasswordMatched AS BYTE ' BOOLEAN PasswordMatched
END TYPE
'//
'// If password change type of check is to be made,
'// this kind of input must be used
'//
'// InputPersistedFields: Information about the account to be logged into
'// ClearPassword: The string which password is going to be
'// UserAccountName: Name of the user account
'// HashedPassword: Hash of the string that the password is going to be
'// PasswordMatch: denotes if the old password supplied by user matched or not
'//
' // Size = 60 bytes
TYPE NET_VALIDATE_PASSWORD_CHANGE_INPUT_ARG DWORD
 InputPersistedFields AS NET_VALIDATE_PERSISTED_FIELDS ' NET_VALIDATE_PERSISTED_FIELDS InputPersistedFields
 ClearPassword AS WSTRINGZ PTR ' LPWSTR ClearPassword
 UserAccountName AS WSTRINGZ PTR ' LPWSTR UserAccountName
 HashedPassword AS NET_VALIDATE_PASSWORD_HASH ' NET_VALIDATE_PASSWORD_HASH HashedPassword
 PasswordMatch AS BYTE ' BOOLEAN PasswordMatch
END TYPE
'//
'// If password reset type of check is to be made,
'// this kind of input must be used
'//
'// InputPersistedFields: Information about the account to be logged into
'// ClearPassword: The string which password is going to be
'// UserAccountName: Name of the user account
'// HashedPassword: Hash of the string that the password is going to be
'// PasswordMustChangeAtNextLogon: Password must change for the user to be logged in
'// ClearLockout: If the account was locked out, this field can be used to clear lockout
'//
' // Size = 60 bytes
TYPE NET_VALIDATE_PASSWORD_RESET_INPUT_ARG
 InputPersistedFields AS NET_VALIDATE_PERSISTED_FIELDS ' NET_VALIDATE_PERSISTED_FIELDS InputPersistedFields
 ClearPassword AS WSTRINGZ PTR ' LPWSTR ClearPassword
 UserAccountName AS WSTRINGZ PTR ' LPWSTR UserAccountName
 HashedPassword AS NET_VALIDATE_PASSWORD_HASH ' NET_VALIDATE_PASSWORD_HASH HashedPassword
 PasswordMustChangeAtNextLogon AS BYTE ' BOOLEAN PasswordMustChangeAtNextLogon
 ClearLockout AS BYTE ' BOOLEAN ClearLockout
 alignment__ AS WORD
END TYPE
'//
'// Password Checking API structures end here
'//
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetValidatePasswordPolicy LIB "NetAPI32.dll" ALIAS "NetValidatePasswordPolicy" ( ServerName AS WSTRINGZ, Qualifier AS ANY, BYVAL ValidationType AS LONG, InputArg AS ANY, OutputArg AS ANY ) AS QUAD
#ELSE
DECLARE FUNCTION NetValidatePasswordPolicy LIB "netapi32.dll" ALIAS "NetValidatePasswordPolicy" ( BYREF ServerName AS WSTRINGZ , BYVAL Qualifier AS QUAD , BYVAL ValidationType AS LONG , BYREF InputArg AS ANY , BYREF OutputArg AS ANY ) AS QUAD ' NET_API_STATUS
#ENDIF
DECLARE FUNCTION NetValidatePasswordPolicyFree LIB "netapi32.dll" ALIAS "NetValidatePasswordPolicyFree" ( BYREF OutputArg AS ANY ) AS QUAD ' NET_API_STATUS
#ENDIF ' #IF NOT %DEF(%LMACCESS)
'//
'// Domain Class
'//
#IF NOT %DEF(%LMDOMAIN)
 %LMDOMAIN = 1
'//
'// Function Prototypes - Domain
'//
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetGetDCName LIB "NetAPI32.dll" ALIAS "NetGetDCName" ( servername AS WSTRINGZ, domainname AS WSTRINGZ, BYVAL bufptr AS BYTE PTR ) AS QUAD
#ELSE
DECLARE FUNCTION NetGetDCName LIB "netapi32.dll" ALIAS "NetGetDCName" ( BYREF servername AS WSTRINGZ , BYREF domainname AS WSTRINGZ , BYREF bufptr AS ANY ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetGetAnyDCName LIB "NetAPI32.dll" ALIAS "NetGetAnyDCName" ( servername AS WSTRINGZ, domainname AS WSTRINGZ, BYVAL bufptr AS BYTE PTR ) AS QUAD
#ELSE
DECLARE FUNCTION NetGetAnyDCName LIB "netapi32.dll" ALIAS "NetGetAnyDCName" ( BYREF servername AS WSTRINGZ , BYREF domainname AS WSTRINGZ , BYREF bufptr AS ANY ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION I_NetLogonControl LIB "NetAPI32.dll" ALIAS "I_NetLogonControl" ( servername AS WSTRINGZ, BYVAL FunctionCode AS QUAD, BYVAL QueryLevel AS QUAD, BYVAL Buffer AS BYTE PTR ) AS QUAD
#ELSE
DECLARE FUNCTION I_NetLogonControl LIB "netapi32.dll" ALIAS "I_NetLogonControl" ( BYREF ServerName AS WSTRINGZ , BYVAL FunctionCode AS QUAD , BYVAL QueryLevel AS QUAD , BYREF Buffer AS ANY ) AS QUAD ' NET_API_STATUS
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION I_NetLogonControl2 LIB "NetAPI32.dll" ALIAS "I_NetLogonControl2" ( ServerName AS WSTRINGZ, BYVAL FunctionCode AS QUAD, BYVAL QueryLevel AS QUAD, BYVAL pData AS BYTE PTR, BYVAL Buffer AS BYTE PTR ) AS QUAD
#ELSE
DECLARE FUNCTION I_NetLogonControl2 LIB "netapi32.dll" ALIAS "I_NetLogonControl2" ( BYREF ServerName AS WSTRINGZ , BYVAL FunctionCode AS QUAD , BYVAL QueryLevel AS QUAD , BYREF Data AS ANY , BYREF Buffer AS ANY ) AS QUAD ' NET_API_STATUS
#ENDIF
'#ifndef _NTDEF_
'typedef LONG NTSTATUS, *PNTSTATUS;
'#endif
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetEnumerateTrustedDomains LIB "NetAPI32.dll" ALIAS "NetEnumerateTrustedDomains" ( ServerName AS WSTRINGZ, DomainNames AS ANY ) AS QUAD
#ELSE
DECLARE FUNCTION NetEnumerateTrustedDomains LIB "netapi32.dll" ALIAS "NetEnumerateTrustedDomains" ( BYREF ServerName AS WSTRINGZ , BYREF DomainNames AS QUAD ) AS LONG ' NTSTATUS
#ENDIF
'//
'// Special Values and Constants - Domain
'//
'//
'// FunctionCode values for I_NetLogonControl.
'//
'// NOTE : if you change the following NETLOGON_CONTROL_* values,
'// change them in net\svcdlls\logonsrv\logon.idl file also.
'//
%EQUATE `NETLOGON_CONTROL_QUERY = 1 ' No-op: just query
%EQUATE `NETLOGON_CONTROL_REPLICATE = 2 ' Force replicate on BDC
%EQUATE `NETLOGON_CONTROL_SYNCHRONIZE = 3 ' Force synchronize on BDC
%EQUATE `NETLOGON_CONTROL_PDC_REPLICATE = 4 ' Force PDC to broadcast change
%EQUATE `NETLOGON_CONTROL_REDISCOVER = 5 ' Force to re-discover trusted domain DCs
%EQUATE `NETLOGON_CONTROL_TC_QUERY = 6 ' Query status of specified trusted channel status
%EQUATE `NETLOGON_CONTROL_TRANSPORT_NOTIFY = 7 ' Notify netlogon that a new transport has come online
%EQUATE `NETLOGON_CONTROL_FIND_USER = 8 ' Find named user in a trusted domain
%EQUATE `NETLOGON_CONTROL_CHANGE_PASSWORD = 9 ' Change machine password on a secure channel to a trusted domain
%EQUATE `NETLOGON_CONTROL_TC_VERIFY = 10 ' Verify status of specified trusted channel
%EQUATE `NETLOGON_CONTROL_FORCE_DNS_REG = 11 ' Force DNS re-registration of all registered records
%EQUATE `NETLOGON_CONTROL_QUERY_DNS_REG = 12 ' Query the status of DNS updates
'// Debug function codes
%EQUATE `NETLOGON_CONTROL_UNLOAD_NETLOGON_DLL = &H0000FFFB
%EQUATE `NETLOGON_CONTROL_BACKUP_CHANGE_LOG = &H0000FFFC
%EQUATE `NETLOGON_CONTROL_TRUNCATE_LOG = &H0000FFFD
%EQUATE `NETLOGON_CONTROL_SET_DBFLAG = &H0000FFFE
%EQUATE `NETLOGON_CONTROL_BREAKPOINT = &H0000FFFF
'//
'// Query level 1 for I_NetLogonControl
'//
' // Size = 8 bytes
TYPE NETLOGON_INFO_1 DWORD
 netlog1_flags AS DWORD ' DWORD netlog1_flags
 netlog1_pdc_connection_status AS DWORD ' NET_API_STATUS netlog1_pdc_connection_status
END TYPE
' // Size = 12 bytes
TYPE NETLOGON_INFO_2 DWORD
 netlog2_flags AS DWORD ' DWORD netlog2_flags
 netlog2_pdc_connection_status AS DWORD ' NET_API_STATUS netlog2_pdc_connection_status
 netlog2_trusted_dc_name AS WSTRINGZ PTR ' LPWSTR netlog2_trusted_dc_name
 netlog2_tc_connection_status AS DWORD ' NET_API_STATUS netlog2_tc_connection_status
END TYPE
' // Size = 28 bytes
TYPE NETLOGON_INFO_3 DWORD
 netlog3_flags AS DWORD ' DWORD netlog3_flags
 netlog3_logon_attempts AS DWORD ' DWORD netlog3_logon_attempts
 netlog3_reserved1 AS DWORD ' DWORD netlog3_reserved1
 netlog3_reserved2 AS DWORD ' DWORD netlog3_reserved2
 netlog3_reserved3 AS DWORD ' DWORD netlog3_reserved3
 netlog3_reserved4 AS DWORD ' DWORD netlog3_reserved4
 netlog3_reserved5 AS DWORD ' DWORD netlog3_reserved5
END TYPE
' // Size = 8 bytes
TYPE NETLOGON_INFO_4 DWORD
 netlog4_trusted_dc_name AS WSTRINGZ PTR ' LPWSTR netlog4_trusted_dc_name
 netlog4_trusted_domain_name AS WSTRINGZ PTR ' LPWSTR netlog4_trusted_domain_name
END TYPE
'//
'// Values of netlog1_flags
'//
%EQUATE `NETLOGON_REPLICATION_NEEDED = &H0001 ' Database is out of date
%EQUATE `NETLOGON_REPLICATION_IN_PROGRESS = &H0002 ' Replication is happening now
%EQUATE `NETLOGON_FULL_SYNC_REPLICATION = &H0004 ' full sync replication required/progress
%EQUATE `NETLOGON_REDO_NEEDED = &H0008 ' Redo of previous replication needed
%EQUATE `NETLOGON_HAS_IP = &H0010 ' The trusted domain DC has an IP address
%EQUATE `NETLOGON_HAS_TIMESERV = &H0020 ' The trusted domain DC runs the Windows Time Service
%EQUATE `NETLOGON_DNS_UPDATE_FAILURE = &H0040 ' There was a failure in the last update for one of the DNS records
%EQUATE `NETLOGON_VERIFY_STATUS_RETURNED = &H0080 ' Trust verification status returned in netlog2_pdc_connection_status
'#define SERVICE_ACCOUNT_PASSWORD TEXT("_SA_{262E99C9-6160-4871-ACEC-4E61736B6F21}")
'#define SERVICE_ACCOUNT_SECRET_PREFIX TEXT("_SC_{262E99C9-6160-4871-ACEC-4E61736B6F21}_")
$SERVICE_ACCOUNT_PASSWORD = "_SA_{262E99C9-6160-4871-ACEC-4E61736B6F21}"
$SERVICE_ACCOUNT_SECRET_PREFIX = "_SC_{262E99C9-6160-4871-ACEC-4E61736B6F21}_"
$ServiceAccountPasswordGUID = GUID$("{262E99C9-6160-4871-ACEC-4E61736B6F21}")
DECLARE FUNCTION NetAddServiceAccount LIB "netapi32.dll" ALIAS "NetAddServiceAccount" ( BYREF ServerName AS WSTRINGZ , BYREF AccountName AS WSTRINGZ , BYREF Reserved AS WSTRINGZ , BYVAL Flags AS QUAD ) AS LONG ' NTSTATUS
'// Do not create an account by this name
'// Only link this account to my computer if it exists
%EQUATE `SERVICE_ACCOUNT_FLAG_LINK_TO_HOST_ONLY = &H00000001
'// Do not delete the service account object from AD
'// Simply unlink it from this computer and delete the local secret
%EQUATE `SERVICE_ACCOUNT_FLAG_UNLINK_FROM_HOST_ONLY = &H00000001
DECLARE FUNCTION NetRemoveServiceAccount LIB "netapi32.dll" ALIAS "NetRemoveServiceAccount" ( BYREF ServerName AS WSTRINGZ , BYREF AccountName AS WSTRINGZ , BYVAL Flags AS QUAD ) AS LONG ' NTSTATUS
DECLARE FUNCTION NetEnumerateServiceAccounts LIB "netapi32.dll" ALIAS "NetEnumerateServiceAccounts" ( BYREF ServerName AS WSTRINGZ , BYVAL Flags AS QUAD , BYREF AccountsCount AS QUAD , BYREF Accounts AS ANY ) AS LONG ' NTSTATUS
DECLARE FUNCTION NetIsServiceAccount LIB "netapi32.dll" ALIAS "NetIsServiceAccount" ( BYREF ServerName AS WSTRINGZ , BYREF AccountName AS WSTRINGZ , BYREF IsService AS LONG ) AS LONG ' NTSTATUS
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION NetQueryServiceAccount (ServerName AS WSTRINGZ, AccountName AS WSTRINGZ, BYVAL InfoLevel AS QUAD, Buffer AS ANY) AS LONG
#ELSE
DECLARE FUNCTION NetQueryServiceAccount LIB "netapi32.dll" ALIAS "NetQueryServiceAccount" ( BYREF ServerName AS WSTRINGZ , BYREF AccountName AS WSTRINGZ , BYVAL InfoLevel AS QUAD , BYREF Buffer AS QUAD ) AS LONG ' NTSTATUS
#ENDIF
'//
'// Data Structures - Service
'//
' enum MSA_INFO_LEVEL
%EQUATE `MsaInfoLevel0 = 0
%EQUATE `MsaInfoLevelMax = 1
' enum MSA_INFO_STATE
%EQUATE `MsaInfoNotExist = 1
%EQUATE `MsaInfoNotService = 2
%EQUATE `MsaInfoCannotInstall = 3
%EQUATE `MsaInfoCanInstall = 4
%EQUATE `MsaInfoInstalled = 5
' // Size = 4 bytes
TYPE MSA_INFO_0 DWORD
 State AS LONG ' MSA_INFO_STATE
END TYPE
#ENDIF ' #IF NOT %DEF(%LMDOMAIN)
#ENDIF
