summaryrefslogtreecommitdiff
path: root/ext/ldap
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2000-04-01 16:23:39 +0000
committerZeev Suraski <zeev@php.net>2000-04-01 16:23:39 +0000
commit491a315c11812e7dd595c386c47f86b73676e147 (patch)
tree6e9fa30a5aa607b3838228799847a6c026fd29f9 /ext/ldap
parent131d9cb2dcf256ddf824d0967fb32f34ee5cfbf3 (diff)
downloadphp-git-491a315c11812e7dd595c386c47f86b73676e147.tar.gz
@- Made the IMAP and LDAP modules compilable under Windows and thread-safe (Zeev)
Diffstat (limited to 'ext/ldap')
-rw-r--r--ext/ldap/ldap.c216
-rw-r--r--ext/ldap/ldap.dsp167
-rw-r--r--ext/ldap/php_ldap.h50
3 files changed, 238 insertions, 195 deletions
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index d9ebd79f6a..5980a53bc9 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -16,6 +16,7 @@
| Eric Warnke <ericw@albany.edu> |
| Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
| Gerrit Thomson <334647@swin.edu.au> |
+ | PHP 4.0 updates: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
@@ -24,10 +25,8 @@
#define IS_EXT_MODULE
#include "php.h"
+#include "php_ini.h"
-#if HAVE_LDAP
-
-#include "dl/phpdl.h"
#include "ext/standard/dl.h"
#include "php_ldap.h"
@@ -47,18 +46,11 @@
#include "ext/standard/php_string.h"
-#if THREAD_SAFE & HAVE_NSLDAP
-#include "php3_threads.h"
-/* Structure for LDAP error values */
-#define LDAP_TLS_VARS ldap_module *PHP3_TLS_GET(ldapTLS,php_ldap_module)
-#define LDAP_GLOBAL(a) php_ldap_module->a
-#else
-#define LDAP_TLS_VARS
-#define LDAP_GLOBAL(a) php_ldap_module.a
-ldap_module php_ldap_module;
-#endif
+ZEND_DECLARE_MODULE_GLOBALS(ldap)
+static int le_result, le_result_entry, le_ber_entry;
+static int le_link;
/*
This is just a small subset of the functionality provided by the LDAP library. All the
@@ -104,159 +96,60 @@ zend_module_entry ldap_module_entry = {
-#if COMPILE_DL
-DLEXPORT zend_module_entry *get_module(void ) { return &ldap_module_entry; }
+#ifdef COMPILE_DL_LDAP
+ZEND_DLEXPORT zend_module_entry *get_module(void ) { return &ldap_module_entry; }
#endif
-#if 0 /* see my note in php_ldap.h. smc */
-/* Function for setting thread-specific LDAP error values */
-static void php_ldap_set_ld_error( int err, char *matched, char *errmsg, void *dummy )
+static void _close_ldap_link(LDAP *ld)
{
- LDAP_TLS_VARS;
-
- /* Set the error code returned by the LDAP operation */
- LDAP_GLOBAL(le_errno) = err;
- /* Specify the components of the DN that matched (if
- an "NO_SUCH_OBJECT" error occurred */
- if ( LDAP_GLOBAL(le_matched) != NULL ) {
- ldap_memfree( LDAP_GLOBAL(le_matched) );
- }
- LDAP_GLOBAL(le_matched) = matched;
- /* Specify the error message corresponding to the error code */
- if ( LDAP_GLOBAL(le_errmsg) != NULL ) {
- ldap_memfree( LDAP_GLOBAL(le_errmsg) );
- }
- LDAP_GLOBAL(le_errmsg) = errmsg;
-}
+ LDAPLS_FETCH();
-/* Function for getting the thread-specific LDAP error values */
-static int php_ldap_get_ld_error( char **matched, char **errmsg, void *dummy )
-{
- LDAP_TLS_VARS;
- /* Retrieve the error values */
- if ( matched != NULL ) {
- *matched = LDAP_GLOBAL(le_matched);
- }
- if ( errmsg != NULL ) {
- *errmsg = LDAP_GLOBAL(le_errmsg);
- }
- return( LDAP_GLOBAL(le_errno) );
+ ldap_unbind_s(ld);
+ /* php_printf("Freeing ldap connection");*/
+ LDAPG(num_links)--;
}
-/* Function for setting the value of the errno variable */
-static void php_ldap_set_errno( int err )
-{
- errno = err;
-}
-/* Function for getting the value of the errno variable */
-static int php_ldap_get_errno( void )
+static void _free_ldap_result(LDAPMessage *result)
{
- return( errno );
+ ldap_msgfree(result);
}
-#endif /* THREAD_SAFE && NSLDAP */
-static void _close_ldap_link(LDAP *ld)
-{
- LDAP_TLS_VARS;
- ldap_unbind_s(ld);
- /* php_printf("Freeing ldap connection");*/
- LDAP_GLOBAL(num_links)--;
-}
+PHP_INI_BEGIN()
+ STD_PHP_INI_ENTRY_EX("ldap.max_links", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_links, zend_ldap_globals, ldap_globals, display_link_numbers)
+ STD_PHP_INI_ENTRY("mysql.base_dn", NULL, PHP_INI_ALL, OnUpdateString, base_dn, zend_ldap_globals, ldap_globals)
+PHP_INI_END()
-static void _free_ldap_result(LDAPMessage *result)
+
+static void php_ldap_init_globals(zend_ldap_globals *ldap_globals)
{
- ldap_msgfree(result);
+ ldap_globals->num_links = 0;
}
+
PHP_MINIT_FUNCTION(ldap)
{
-#if defined(THREAD_SAFE)
- ldap_module *php_ldap_module;
- PHP_MUTEX_ALLOC(ldap_mutex);
- PHP_MUTEX_LOCK(ldap_mutex);
- numthreads++;
- if (numthreads==1){
- if (!PHP3_TLS_PROC_STARTUP(ldapTLS)){
- PHP_MUTEX_UNLOCK(ldap_mutex);
- PHP_MUTEX_FREE(ldap_mutex);
- return 0;
- }
- }
- PHP_MUTEX_UNLOCK(ldap_mutex);
- if(!PHP3_TLS_THREAD_INIT(ldapTLS,php_ldap_module,ldap_module))
- return 0;
-#if 0 /*HAVE_NSLDAP*/
- /* Set up the ldap_thread_fns structure with pointers
- to the functions that you want called */
- memset( &LDAP_GLOBAL(tfns), '\0', sizeof(struct ldap_thread_fns) );
- /* Specify the functions that you want called */
- /* Call the my_mutex_alloc() function whenever mutexes
- need to be allocated */
- LDAP_GLOBAL(tfns).ltf_mutex_alloc = (void *(*)(void)) php3_mutex_alloc;
- /* Call the my_mutex_free() function whenever mutexes
- need to be destroyed */
- LDAP_GLOBAL(tfns).ltf_mutex_free = (void (*)(void *)) php3_mutex_free;
- /* Call the pthread_mutex_lock() function whenever a
- thread needs to lock a mutex. */
- LDAP_GLOBAL(tfns).ltf_mutex_lock = (int (*)(void *)) php3_mutex_lock;
- /* Call the pthread_mutex_unlock() function whenever a
- thread needs to unlock a mutex. */
- LDAP_GLOBAL(tfns).ltf_mutex_unlock = (int (*)(void *)) php3_mutex_unlock;
- /* Call the get_errno() function to get the value of errno */
- LDAP_GLOBAL(tfns).ltf_get_errno = php_ldap_get_errno;
- /* Call the set_errno() function to set the value of errno */
- LDAP_GLOBAL(tfns).ltf_set_errno = php_ldap_set_errno;
- /* Call the get_ld_error() function to get error values from
- calls to functions in the libldap library */
- LDAP_GLOBAL(tfns).ltf_get_lderrno = php_ldap_get_ld_error;
- /* Call the set_ld_error() function to set error values for
- calls to functions in the libldap library */
- LDAP_GLOBAL(tfns).ltf_set_lderrno = php_ldap_set_ld_error;
- /* Don't pass any extra parameter to the functions for
- getting and setting libldap function call errors */
- LDAP_GLOBAL(tfns).ltf_lderrno_arg = NULL;
-/* Set the session option that specifies the functions to call for multi-threaded clients */
- if (ldap_set_option( ld, LDAP_OPT_THREAD_FN_PTRS, (void *) &LDAP_GLOBAL(tfns))!= 0) {
- ldap_perror( ld, "ldap_set_option: thread pointers" );
- }
-#endif
-#endif
- if (cfg_get_long("ldap.max_links", &LDAP_GLOBAL(max_links)) == FAILURE) {
- LDAP_GLOBAL(max_links) = -1;
- }
+ ZEND_INIT_MODULE_GLOBALS(ldap, php_ldap_init_globals, NULL);
- if (cfg_get_string("ldap.base_dn", &LDAP_GLOBAL(base_dn)) == FAILURE) {
- LDAP_GLOBAL(base_dn) = NULL;
- }
+ REGISTER_INI_ENTRIES();
- LDAP_GLOBAL(le_result) = register_list_destructors(_free_ldap_result, NULL);
- LDAP_GLOBAL(le_link) = register_list_destructors(_close_ldap_link, NULL);
+ le_result = register_list_destructors(_free_ldap_result, NULL);
+ le_link = register_list_destructors(_close_ldap_link, NULL);
- /*FIXME is this safe in threaded environment? if so, please comment*/
ldap_module_entry.type = type;
return SUCCESS;
}
+
PHP_MSHUTDOWN_FUNCTION(ldap)
{
-#ifdef THREAD_SAFE
- LDAP_TLS_VARS;
- PHP3_TLS_THREAD_FREE(php_ldap_module);
- PHP_MUTEX_LOCK(ldap_mutex);
- numthreads--;
- if (!numthreads) {
- PHP3_TLS_PROC_SHUTDOWN(ldapTLS);
- }
- PHP_MUTEX_UNLOCK(ldap_mutex);
- PHP_MUTEX_FREE(ldap_mutex);
-#endif
return SUCCESS;
}
+
PHP_MINFO_FUNCTION(ldap)
{
char maxl[16];
@@ -266,12 +159,12 @@ PHP_MINFO_FUNCTION(ldap)
/* Print version information */
SDKVersion = ldap_version( &ver );
#endif
- LDAP_TLS_VARS;
+ LDAPLS_FETCH();
- if (LDAP_GLOBAL(max_links) == -1) {
+ if (LDAPG(max_links) == -1) {
strcpy(maxl, "Unlimited");
} else {
- snprintf(maxl, 15, "%ld", LDAP_GLOBAL(max_links));
+ snprintf(maxl, 15, "%ld", LDAPG(max_links));
maxl[15] = 0;
}
@@ -283,7 +176,7 @@ PHP_MINFO_FUNCTION(ldap)
"<tr><td>Highest LDAP Protocol Supported:</td><td>%f</td></tr>"
"<tr><td>SSL Level Supported:</td><td>%f</td></tr>"
#endif
- ,LDAP_GLOBAL(num_links),maxl
+ ,LDAPG(num_links), maxl
#if HAVE_NSLDAP
,SDKVersion/100.0,ver.protocol_version/100.0,ver.SSL_version/100.0
#endif
@@ -308,7 +201,7 @@ PHP_FUNCTION(ldap_connect)
/* char *hashed_details;
int hashed_details_length;*/
LDAP *ldap;
- LDAP_TLS_VARS;
+ LDAPLS_FETCH();
switch(ARG_COUNT(ht)) {
case 0:
@@ -359,16 +252,16 @@ PHP_FUNCTION(ldap_connect)
break;
}
- if (LDAP_GLOBAL(max_links)!=-1 && LDAP_GLOBAL(num_links)>=LDAP_GLOBAL(max_links)) {
- php_error(E_WARNING, "LDAP: Too many open links (%d)", LDAP_GLOBAL(num_links));
- RETURN_FALSE;
+ if (LDAPG(max_links)!=-1 && LDAPG(num_links)>=LDAPG(max_links)) {
+ php_error(E_WARNING, "LDAP: Too many open links (%d)", LDAPG(num_links));
+ RETURN_FALSE;
}
ldap = ldap_open(host,port);
if ( ldap == NULL ) {
- RETURN_FALSE;
+ RETURN_FALSE;
} else {
- RETURN_LONG(zend_list_insert((void*)ldap,LDAP_GLOBAL(le_link)));
+ RETURN_LONG(zend_list_insert((void*)ldap,le_link));
}
}
@@ -379,12 +272,12 @@ static LDAP * _get_ldap_link(pval **link)
{
LDAP *ldap;
int type;
- LDAP_TLS_VARS;
+ LDAPLS_FETCH();
convert_to_long_ex(link);
ldap = (LDAP *) zend_list_find((*link)->value.lval, &type);
- if (!ldap || !(type == LDAP_GLOBAL(le_link))) {
+ if (!ldap || !(type == le_link)) {
php_error(E_WARNING, "%d is not a LDAP link index",(*link)->value.lval);
return NULL;
}
@@ -396,12 +289,12 @@ static LDAPMessage * _get_ldap_result(pval **result)
{
LDAPMessage *ldap_result;
int type;
- LDAP_TLS_VARS;
+ LDAPLS_FETCH();
convert_to_long_ex(result);
ldap_result = (LDAPMessage *)zend_list_find((*result)->value.lval, &type);
- if (!ldap_result || type != LDAP_GLOBAL(le_result)) {
+ if (!ldap_result || type != le_result) {
php_error(E_WARNING, "%d is not a LDAP result index",(*result)->value.lval);
return NULL;
}
@@ -414,12 +307,12 @@ static LDAPMessage * _get_ldap_result_entry(pval **result)
{
LDAPMessage *ldap_result_entry;
int type;
- LDAP_TLS_VARS;
+ LDAPLS_FETCH();
convert_to_long_ex(result);
ldap_result_entry = (LDAPMessage *)zend_list_find((*result)->value.lval, &type);
- if (!ldap_result_entry || type != LDAP_GLOBAL(le_result_entry)) {
+ if (!ldap_result_entry || type != le_result_entry) {
php_error(E_WARNING, "%d is not a LDAP result entry index", (*result)->value.lval);
return NULL;
}
@@ -432,12 +325,12 @@ static BerElement * _get_ber_entry(pval **berp)
{
BerElement *ber;
int type;
- LDAP_TLS_VARS;
+ LDAPLS_FETCH();
convert_to_long_ex(berp);
ber = (BerElement *) zend_list_find((*berp)->value.lval, &type);
- if ( type != LDAP_GLOBAL(le_ber_entry)) {
+ if ( type != le_ber_entry) {
php_error(E_WARNING, "%d is not a BerElement index",(*berp)->value.lval);
return NULL;
}
@@ -546,7 +439,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
int attrsonly;
LDAPMessage *ldap_result;
int num_attribs=0, i;
- LDAP_TLS_VARS;
+ LDAPLS_FETCH();
switch(ARG_COUNT(ht)) {
case 3 :
@@ -628,7 +521,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
#endif
RETVAL_FALSE;
} else {
- RETVAL_LONG(zend_list_insert(ldap_result, LDAP_GLOBAL(le_result)));
+ RETVAL_LONG(zend_list_insert(ldap_result, le_result));
}
if (ldap_attrs != NULL) {
@@ -715,7 +608,7 @@ PHP_FUNCTION(ldap_first_entry)
LDAP *ldap;
LDAPMessage *ldap_result;
LDAPMessage *ldap_result_entry;
- LDAP_TLS_VARS;
+ LDAPLS_FETCH();
if (ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &link, &result) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -730,7 +623,7 @@ PHP_FUNCTION(ldap_first_entry)
if ((ldap_result_entry = ldap_first_entry(ldap, ldap_result)) == NULL) {
RETURN_FALSE;
} else {
- RETURN_LONG(zend_list_insert(ldap_result_entry, LDAP_GLOBAL(le_result_entry)));
+ RETURN_LONG(zend_list_insert(ldap_result_entry, le_result_entry));
}
}
/* }}} */
@@ -742,7 +635,7 @@ PHP_FUNCTION(ldap_next_entry)
pval **result_entry, **link;
LDAP *ldap;
LDAPMessage *ldap_result_entry, *ldap_result_entry_next;
- LDAP_TLS_VARS;
+ LDAPLS_FETCH();
if (ARG_COUNT(ht) != 2 || zend_get_parameters_ex(2, &link,&result_entry) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -757,7 +650,7 @@ PHP_FUNCTION(ldap_next_entry)
if ((ldap_result_entry_next = ldap_next_entry(ldap, ldap_result_entry)) == NULL) {
RETURN_FALSE;
} else {
- RETURN_LONG(zend_list_insert(ldap_result_entry_next, LDAP_GLOBAL(le_result_entry)));
+ RETURN_LONG(zend_list_insert(ldap_result_entry_next, le_result_entry));
}
}
/* }}} */
@@ -858,7 +751,7 @@ PHP_FUNCTION(ldap_first_attribute)
LDAPMessage *ldap_result_entry;
BerElement *ber;
char *attribute;
- LDAP_TLS_VARS;
+ LDAPLS_FETCH();
if (ARG_COUNT(ht) != 3 || zend_get_parameters_ex(3, &link,&result,&berp) == FAILURE || ParameterPassedByReference(ht,3)==0 ) {
WRONG_PARAM_COUNT;
@@ -875,7 +768,7 @@ PHP_FUNCTION(ldap_first_attribute)
} else {
/* brep is passed by ref so we do not have to account for memory */
(*berp)->type=IS_LONG;
- (*berp)->value.lval=zend_list_insert(ber,LDAP_GLOBAL(le_ber_entry));
+ (*berp)->value.lval=zend_list_insert(ber,le_ber_entry);
RETVAL_STRING(attribute,1);
#ifdef WINDOWS
@@ -1302,4 +1195,3 @@ PHP_FUNCTION(ldap_delete)
}
/* }}} */
-#endif
diff --git a/ext/ldap/ldap.dsp b/ext/ldap/ldap.dsp
new file mode 100644
index 0000000000..0747aaacc5
--- /dev/null
+++ b/ext/ldap/ldap.dsp
@@ -0,0 +1,167 @@
+# Microsoft Developer Studio Project File - Name="ldap" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=ldap - Win32 Debug_TS
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "ldap.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "ldap.mak" CFG="ldap - Win32 Debug_TS"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ldap - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "ldap - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "ldap - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "ldap - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "ldap - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LDAP_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "..\..\..\php_build\openldap\include" /D "NDEBUG" /D ZEND_DEBUG=0 /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LDAP_EXPORTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_LDAP=1 /D "COMPILE_DL_LDAP" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 oldap32.lib olber32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib php4nts.lib /nologo /dll /machine:I386 /libpath:"..\..\Release" /libpath:"..\..\..\php_build\openldap\libraries\Release"
+
+!ELSEIF "$(CFG)" == "ldap - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LDAP_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "..\..\..\php_build\openldap\include" /D "_DEBUG" /D ZEND_DEBUG=1 /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LDAP_EXPORTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_LDAP=1 /D "COMPILE_DL_LDAP" /FR /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 oldap32.lib olber32.lib php4nts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\Debug" /libpath:"..\..\..\php_build\openldap\libraries\Debug"
+
+!ELSEIF "$(CFG)" == "ldap - Win32 Debug_TS"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ldap___Win32_Debug_TS"
+# PROP BASE Intermediate_Dir "ldap___Win32_Debug_TS"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug_TS"
+# PROP Intermediate_Dir "Debug_TS"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "..\..\..\openldap\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LDAP_EXPORTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_LDAP=1 /D ZEND_DEBUG=1 /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "..\..\..\php_build\openldap\include" /D "_DEBUG" /D ZEND_DEBUG=1 /D "ZTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LDAP_EXPORTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_LDAP=1 /D "COMPILE_DL_LDAP" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 oldap32.lib olber32.lib php4nts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\openldap\libraries\Debug" /libpath:"..\..\Debug"
+# ADD LINK32 oldap32.lib olber32.lib php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\Debug_TS" /libpath:"..\..\..\php_build\openldap\libraries\Debug"
+
+!ELSEIF "$(CFG)" == "ldap - Win32 Release_TS"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ldap___Win32_Release_TS"
+# PROP BASE Intermediate_Dir "ldap___Win32_Release_TS"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release_TS"
+# PROP Intermediate_Dir "Release_TS"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "..\..\..\openldap\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LDAP_EXPORTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_LDAP=1 /D ZEND_DEBUG=0 /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "..\..\..\php_build\openldap\include" /D "NDEBUG" /D ZEND_DEBUG=0 /D "ZTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LDAP_EXPORTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_LDAP=1 /D "COMPILE_DL_LDAP" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 oldap32.lib olber32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib php4nts.lib /nologo /dll /machine:I386 /libpath:"..\..\..\openldap\libraries\Release" /libpath:"..\..\Release"
+# ADD LINK32 oldap32.lib olber32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib php4ts.lib /nologo /dll /machine:I386 /libpath:"..\..\Release_TS" /libpath:"..\..\..\php_build\openldap\libraries\Release"
+
+!ENDIF
+
+# Begin Target
+
+# Name "ldap - Win32 Release"
+# Name "ldap - Win32 Debug"
+# Name "ldap - Win32 Debug_TS"
+# Name "ldap - Win32 Release_TS"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\ldap.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\php_ldap.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/ext/ldap/php_ldap.h b/ext/ldap/php_ldap.h
index 1e691f93c3..a8e03a59c1 100644
--- a/ext/ldap/php_ldap.h
+++ b/ext/ldap/php_ldap.h
@@ -34,12 +34,6 @@
#ifndef _PHP_LDAP_H
#define _PHP_LDAP_H
-#if COMPILE_DL
-#undef HAVE_LDAP
-#define HAVE_LDAP 1
-#endif
-
-#if HAVE_LDAP
#include <lber.h>
#include <ldap.h>
@@ -89,39 +83,29 @@ PHP_FUNCTION(ldap_mod_add);
PHP_FUNCTION(ldap_mod_replace);
PHP_FUNCTION(ldap_mod_del);
-typedef struct {
+ZEND_BEGIN_MODULE_GLOBALS(ldap)
long default_link;
long num_links, max_links;
char *base_dn;
- int le_result, le_result_entry, le_ber_entry;
- int le_link;
-
- /* I just found out that the thread safe features
- of the netscape ldap library are only required if
- multiple threads are accessing the same LDAP
- structure. Since we are not doing that, we do
- not need to use this feature. I am leaving the
- code here anyway just in case. smc
- */
-#if 0
- struct ldap_thread_fns tfns;
- int le_errno; /* Corresponds to the LDAP error code */
- char *le_matched; /* Matching components of the DN,
- if an NO_SUCH_OBJECT error occurred */
- char *le_errmsg; /* Error message */
-#endif
-} ldap_module;
-
-#ifndef THREAD_SAFE
-extern ldap_module php_ldap_module;
-#endif
-
+ZEND_END_MODULE_GLOBALS(ldap)
+
+#ifdef ZTS
+# define LDAPLS_D zend_ldap_globals *ldap_globals
+# define LDAPLS_DC , LDAPLS_D
+# define LDAPLS_C ldap_globals
+# define LDAPLS_CC , LDAPLS_C
+# define LDAPG(v) (ldap_globals->v)
+# define LDAPLS_FETCH() zend_ldap_globals *ldap_globals = ts_resource(ldap_globals_id)
#else
-
-#define ldap_module_ptr NULL
-
+# define LDAPLS_D
+# define LDAPLS_DC
+# define LDAPLS_C
+# define LDAPLS_CC
+# define LDAPG(v) (ldap_globals.v)
+# define LDAPLS_FETCH()
#endif
+
#define phpext_ldap_ptr ldap_module_ptr
#endif /* _PHP_LDAP_H */