' ########################################################################################
' Microsoft Windows
' File: MSChapp.inc
' 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_MSChapp_PBI)
#DEFINE PBX_MSChapp_PBI
%MSCHAPP_INC = 1
'/*++
'Copyright (C) Microsoft Corporation, 1999
'Module Name:
' mschapp - MS-CHAP Password Change API
'Abstract:
' These APIs correspond to the MS-CHAP RFC -2433 sections 9 and 10. In order
' to develop an MS-CHAP RAS server that works with an NT domain, these APIs
' are required.
' Only wide (Unicode) versions of these apis will be available. These are the
' 2 callable APIs:
' * MSChapSrvChangePassword
' * MsChapSrvChangePassword2
'--*/
'#ifndef _NTCRYPT_
#include once "subauth.inc"
' Declared in subauth.inc
'%CYPHER_BLOCK_LENGTH = 8
' Declared in subauth.inc
'TYPE CYPHER_BLOCK
' data AS STRING * %CYPHER_BLOCK_LENGTH ' CHAR data[CYPHER_BLOCK_LENGTH]
'END TYPE
' Declared in subauth.inc
'TYPE LM_OWF_PASSWORD
' data(1) AS CYPHER_BLOCK ' CYPHER_BLOCK data[2]
'END TYPE
'MACRO NT_OWF_PASSWORD = LM_OWF_PASSWORD
' // Size = 516 bytes
TYPE SAMPR_ENCRYPTED_USER_PASSWORD BYTE
 Buffer AS STRING * (256 * 2) + 4 ' UCHAR Buffer[ (256 * 2) + 4 ];
END TYPE
' // Size = 16 bytes
TYPE ENCRYPTED_LM_OWF_PASSWORD BYTE
 data(1) AS CYPHER_BLOCK ' CYPHER_BLOCK data[2];
END TYPE
MACRO ENCRYPTED_NT_OWF_PASSWORD = ENCRYPTED_LM_OWF_PASSWORD
'#endif
'//
'// Change a password.
'//
DECLARE FUNCTION MSChapSrvChangePassword LIB "advapi32.dll" ALIAS "MSChapSrvChangePassword" ( BYREF ServerName AS WSTRINGZ , BYREF UserName AS WSTRINGZ , BYVAL LmOldPresent AS BYTE , BYREF LmOldOwfPassword AS LM_OWF_PASSWORD , BYREF LmNewOwfPassword AS LM_OWF_PASSWORD , BYREF NtOldOwfPassword AS NT_OWF_PASSWORD , BYREF NtNewOwfPassword AS NT_OWF_PASSWORD ) AS QUAD
'//
'// Change a password using mutual encryption.
'//
DECLARE FUNCTION MSChapSrvChangePassword2 LIB "advapi32.dll" ALIAS "MSChapSrvChangePassword2" ( BYREF ServerName AS WSTRINGZ , BYREF UserName AS WSTRINGZ , BYREF NewPasswordEncryptedWithOldNt AS SAMPR_ENCRYPTED_USER_PASSWORD , BYREF OldNtOwfPasswordEncryptedWithNewNt AS ENCRYPTED_NT_OWF_PASSWORD , BYVAL LmPresent AS BYTE , BYREF NewPasswordEncryptedWithOldLm AS SAMPR_ENCRYPTED_USER_PASSWORD , BYREF OldLmOwfPasswordEncryptedWithNewLmOrNt AS ENCRYPTED_LM_OWF_PASSWORD ) AS QUAD