' ########################################################################################
' Microsoft Windows
' File: dssec.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_dssec_PBI)
#DEFINE PBX_dssec_PBI
%EQUATE `DSSEC_INC = 1
#INCLUDE ONCE "Legacy/Security/AclUI.inc" ' // LPSECURITYINFO
'//+---------------------------------------------------------------------------
'//
'// Function: PFNREADOBJECTSECURITY
'//
'// Synopsis: Reads the security descriptor of a DS object
'//
'// Arguments: [IN LPCWSTR] -- ADS path of DS Object
'// [IN SECURITY_INFORMATION] -- Which SD parts to read
'// [OUT PSECURITY_DESCRIPTOR*] -- Return SD here. Caller frees with LocalFree
'// [IN LPARAM] -- Context param
'//
'// Return: HRESULT
'//
'//----------------------------------------------------------------------------
'//
'// Function: PFNWRITEOBJECTSECURITY
'//
'// Synopsis: Writes a security descriptor to a DS object
'//
'// Arguments: [IN LPCWSTR] -- ADS path of DS Object
'// [IN SECURITY_INFORMATION] -- Which SD parts to write
'// [OUT PSECURITY_DESCRIPTOR] -- Security descriptor to write
'// [IN LPARAM] -- Context param
'//
'// Return: HRESULT
'//
'//----------------------------------------------------------------------------
'typedef HRESULT (WINAPI *PFNREADOBJECTSECURITY)(LPCWSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR*, LPARAM);
'typedef HRESULT (WINAPI *PFNWRITEOBJECTSECURITY)(LPCWSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, LPARAM);
'FUNCTION READOBJECTSECURITY ( ' BYREF pwszAdsPath AS WSTRINGZ ' IN LPCWSTR
' , BYVAL secinfo AS SECURITY_INFORMATION ' IN SECURITY_INFORMATION
' , BYREF sd AS SECURITY_DESCRIPTOR ' OUT PSECURITY_DESCRIPTOR
' , BYVAL lParam AS LONG ' IN LPARAM
' ) AS LONG
'END FUNCTION
'FUNCTION WRITEOBJECTSECURITY ( ' BYREF pwszAdsPath AS WSTRINGZ ' IN LPCWSTR
' , BYVAL secinfo AS SECURITY_INFORMATION ' IN SECURITY_INFORMATION
' , BYREF sd AS SECURITY_DESCRIPTOR ' OUT PSECURITY_DESCRIPTOR
' , BYVAL lParam AS LONG ' IN LPARAM
' ) AS LONG
'END FUNCTION
'//+---------------------------------------------------------------------------
'//
'// Function: DSCreateISecurityInfoObject
'//
'// Synopsis: Instantiates an ISecurityInfo interface for a DS object
'//
'// Arguments: [IN pwszObjectPath] -- Full ADS path of DS object
'// [IN pwszObjectClass] -- Class of the object (optional)
'// [IN dwFlags] -- Combination of DSSI_* flags
'// [OUT ppSI] -- Interface pointer returned here
'// [IN pfnReadSD] -- Optional function for reading SD
'// [IN pfnWriteSD] -- Optional function for writing SD
'// [IN LPARAM] -- Passed to pfnReadSD/pfnWriteSD
'//
'// Return: HRESULT
'//
'//----------------------------------------------------------------------------
DECLARE FUNCTION DSCreateISecurityInfoObject LIB "dssec.dll" ALIAS "DSCreateISecurityInfoObject" ( BYREF pwszObjectPath AS WSTRINGZ , BYREF pwszObjectClass AS WSTRINGZ , BYVAL dwFlags AS QUAD , BYREF ppSI AS ISecurityInformation , BYVAL pfnReadSD AS QUAD , BYVAL pfnWriteSD AS QUAD , BYVAL lpContext AS LONG ) AS LONG
%EQUATE `DSSI_READ_ONLY = &H00000001
%EQUATE `DSSI_NO_ACCESS_CHECK = &H00000002
%EQUATE `DSSI_NO_EDIT_SACL = &H00000004
%EQUATE `DSSI_NO_EDIT_OWNER = &H00000008
%EQUATE `DSSI_IS_ROOT = &H00000010
%EQUATE `DSSI_NO_FILTER = &H00000020
%EQUATE `DSSI_NO_READONLY_MESSAGE = &H00000040
'//
'// Same as above, with optional server, user & password arguments.
'// If use & password are not provided, ADSI defaults are used.
'// If the server is not provided, it is obtained from the object
'// path or DsGetDcName.
'//
DECLARE FUNCTION DSCreateISecurityInfoObjectEx LIB "dssec.dll" ALIAS "DSCreateISecurityInfoObjectEx" ( BYREF pwszObjectPath AS WSTRINGZ , BYREF pwszObjectClass AS WSTRINGZ , BYREF pwszServer AS WSTRINGZ , BYREF pwszUserName AS WSTRINGZ , BYREF pwszPassword AS WSTRINGZ , BYVAL dwFlags AS QUAD , BYREF ppSI AS ISecurityInformation , BYVAL pfnReadSD AS QUAD , BYVAL pfnWriteSD AS QUAD , BYVAL lpContext AS LONG ) AS LONG
'//+---------------------------------------------------------------------------
'//
'// Function: DSCreateSecurityPage
'//
'// Synopsis: Creates a Security property page for a DS object
'//
'// Arguments: [IN pwszObjectPath] -- Full ADS path of DS object
'// [IN pwszObjectClass] -- Class of the object (optional)
'// [IN dwFlags] -- Combination of DSSI_* flags
'// [OUT phPage] -- HPROPSHEETPAGE returned here
'// [IN pfnReadSD] -- Optional function for reading SD
'// [IN pfnWriteSD] -- Optional function for writing SD
'// [IN LPARAM] -- Passed to pfnReadSD/pfnWriteSD
'//
'// Return: HRESULT
'//
'//----------------------------------------------------------------------------
DECLARE FUNCTION DSCreateSecurityPage LIB "dssec.dll" ALIAS "DSCreateSecurityPage" ( BYREF pwszObjectPath AS WSTRINGZ , BYREF pwszObjectClass AS WSTRINGZ , BYVAL dwFlags AS QUAD , BYREF phPage AS QUAD , BYVAL pfnReadSD AS QUAD , BYVAL pfnWriteSD AS QUAD , BYVAL lpContext AS LONG ) AS LONG
'//+---------------------------------------------------------------------------
'//
'// Function: DSEditSecurity
'//
'// Synopsis: Displays a modal dialog for editing security on a DS object
'//
'// Arguments: [IN hwndOwner] -- Dialog owner window
'// [IN pwszObjectPath] -- Full ADS path of DS object
'// [IN pwszObjectClass] -- Class of the object (optional)
'// [IN dwFlags] -- Combination of DSSI_* flags
'// [IN pwszCaption] -- Optional dialog caption
'// [IN pfnReadSD] -- Optional function for reading SD
'// [IN pfnWriteSD] -- Optional function for writing SD
'// [IN LPARAM] -- Passed to pfnReadSD/pfnWriteSD
'//
'// Return: HRESULT
'//
'//----------------------------------------------------------------------------
DECLARE FUNCTION DSEditSecurity LIB "dssec.dll" ALIAS "DSEditSecurity" ( BYREF pwszObjectPath AS WSTRINGZ , BYREF pwszObjectClass AS WSTRINGZ , BYVAL dwFlags AS QUAD , BYREF pwszCaption AS WSTRINGZ , BYVAL pfnReadSD AS QUAD , BYVAL pfnWriteSD AS QUAD , BYVAL lpContext AS LONG ) AS LONG
'FUNCTION DSCREATEISECINFO ( ' BYREF pwszObjectPath AS WSTRINGZ
' , BYREF pwszObjectClass AS WSTRINGZ
' , BYVAL dwFlags AS DWORD
' , BYREF ppSI AS ISecurityInformation
' , BYVAL pfnReadSD AS DWORD
' , BYVAL pfnWriteSD AS DWORD
' , BYVAL lpContext AS LONG
' ) AS LONG
'END FUNCTION
'FUNCTION DSCREATEISECINFOEX ( ' BYREF pwszObjectPath AS WSTRINGZ
' , BYREF pwszObjectClass AS WSTRINGZ
' , BYREF pwszServer AS WSTRINGZ
' , BYREF pwszUserName AS WSTRINGZ
' , BYREF pwszPassword AS WSTRINGZ
' , BYVAL dwFlags AS DWORD
' , BYREF ppSI AS ISecurityInformation
' , BYVAL pfnReadSD AS DWORD
' , BYVAL pfnWriteSD AS DWORD
' , BYVAL lpContext AS LONG
' ) AS LONG
'END FUNCTION
'FUNCTION DSCREATESECPAGE ( ' BYREF pwszObjectPath AS WSTRINGZ
' , BYREF pwszObjectClass AS WSTRINGZ
' , BYVAL dwFlags AS DWORD
' , BYREF phPage AS DWORD
' , BYVAL pfnReadSD AS DWORD
' , BYVAL pfnWriteSD AS DWORD
' , BYVAL lParam AS LONG
' ) AS LONG
'END FUNCTION
'FUNCTION DSEDITSECURITY ( ' BYREF pwszObjectPath AS WSTRINGZ
' , BYREF pwszObjectClass AS WSTRINGZ
' , BYVAL dwFlags AS DWORD
' , BYREF pwszCaption AS WSTRINGZ
' , BYVAL pfnReadSD AS DWORD
' , BYVAL pfnWriteSD AS DWORD
' , BYVAL lpContext AS LONG
' ) AS LONG
'END FUNCTION
#ENDIF
