@@ -186,6 +186,9 @@ PHP_MINIT_FUNCTION(ldap)
186
186
REGISTER_LONG_CONSTANT ("LDAP_OPT_NETWORK_TIMEOUT" , LDAP_OPT_NETWORK_TIMEOUT , CONST_PERSISTENT | CONST_CS );
187
187
#elif defined (LDAP_X_OPT_CONNECT_TIMEOUT )
188
188
REGISTER_LONG_CONSTANT ("LDAP_OPT_NETWORK_TIMEOUT" , LDAP_X_OPT_CONNECT_TIMEOUT , CONST_PERSISTENT | CONST_CS );
189
+ #endif
190
+ #ifdef LDAP_OPT_TIMEOUT
191
+ REGISTER_LONG_CONSTANT ("LDAP_OPT_TIMEOUT" , LDAP_OPT_TIMEOUT , CONST_PERSISTENT | CONST_CS );
189
192
#endif
190
193
REGISTER_LONG_CONSTANT ("LDAP_OPT_PROTOCOL_VERSION" , LDAP_OPT_PROTOCOL_VERSION , CONST_PERSISTENT | CONST_CS );
191
194
REGISTER_LONG_CONSTANT ("LDAP_OPT_ERROR_NUMBER" , LDAP_OPT_ERROR_NUMBER , CONST_PERSISTENT | CONST_CS );
@@ -2118,6 +2121,25 @@ PHP_FUNCTION(ldap_get_option)
2118
2121
zval_ptr_dtor (retval );
2119
2122
ZVAL_LONG (retval , (timeout / 1000 ));
2120
2123
} break ;
2124
+ #endif
2125
+ #ifdef LDAP_OPT_TIMEOUT
2126
+ case LDAP_OPT_TIMEOUT :
2127
+ {
2128
+ struct timeval * timeout = NULL ;
2129
+
2130
+ if (ldap_get_option (ld -> link , LDAP_OPT_TIMEOUT , (void * ) & timeout )) {
2131
+ if (timeout ) {
2132
+ ldap_memfree (timeout );
2133
+ }
2134
+ RETURN_FALSE ;
2135
+ }
2136
+ if (!timeout ) {
2137
+ RETURN_FALSE ;
2138
+ }
2139
+ zval_dtor (retval );
2140
+ ZVAL_LONG (retval , timeout -> tv_sec );
2141
+ ldap_memfree (timeout );
2142
+ } break ;
2121
2143
#endif
2122
2144
/* options with string value */
2123
2145
case LDAP_OPT_ERROR_STRING :
@@ -2223,6 +2245,19 @@ PHP_FUNCTION(ldap_set_option)
2223
2245
RETURN_FALSE ;
2224
2246
}
2225
2247
} break ;
2248
+ #endif
2249
+ #ifdef LDAP_OPT_TIMEOUT
2250
+ case LDAP_OPT_TIMEOUT :
2251
+ {
2252
+ struct timeval timeout ;
2253
+
2254
+ convert_to_long_ex (newval );
2255
+ timeout .tv_sec = Z_LVAL_PP (newval );
2256
+ timeout .tv_usec = 0 ;
2257
+ if (ldap_set_option (ldap , LDAP_OPT_TIMEOUT , (void * ) & timeout )) {
2258
+ RETURN_FALSE ;
2259
+ }
2260
+ } break ;
2226
2261
#endif
2227
2262
/* options with string value */
2228
2263
case LDAP_OPT_ERROR_STRING :
0 commit comments