Sample .CPP file
The following sample .CPP file demonstrates how to construct this DLL. The sample source code assumes the 32-bit edition of Visual C++. Different compilers may require different calling conventions. If Microsoft Visual Studio is used to create the DLL, the Visual Studio project should be created as a Win32 Dynamic Link Library. Use the following defaults for the project settings.
#include <stdio.h> #include <windows.h> #include <winldap.h> BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } #ifdef __cplusplus #define ADS_C_PROTO extern "C" #else #define ADS_C_PROTO #endif // this exit is called immediately prior to the creation of the ADS object // logfile is NULL or if ADS logging is enabled // a handle to PS_HOME\Logs\ADS\eTrustDirectoryName.log ADS_C_PROTO __declspec(dllexport) int _cdecl PreAdd(const PWCHAR pszDN, LDAPModW *ppmods[], FILE *logfile) { // example to print fully distinguished name of ADS object wprintf(L"In PreAdd %s\n", pszDN); if (logfile != NULL) fwprintf(logfile, L”PreAdd %s\n”, pszDN) ; return 0; // return 0 to let the ADS option create the object. // return -1 to stop creation of the object } // this exit is called immediately after the creation of the ADS object ADS_C_PROTO __declspec(dllexport) int _cdecl PostAdd(const PWCHAR pszDN, LDAPModW *ppmods[], FILE *logfile) { // example to print fully distinguished name of ADS object // and list the string based attribute values used to create the object wprintf(L"In PostAdd %s\n", pszDN); for (int i=0; ppmods[i] != NULL; i++) { if (!(ppmods[i]->mod_op & LDAP_MOD_BVALUES)) { // string data wprintf(L"Attribute name: %s\n", ppmods[i]->mod_type); for (int j=0; ppmods[i]->mod_vals.modv_strvals[j] != NULL; j++) wprintf(L" Attribute value %d)%s\n", j, ppmods[i]->mod_vals.modv_strvals[j]); } } return 0; // return 0 to indicate success // return -1 to indicate an error }
Copyright © 2013 CA.
All rights reserved.
|
|