* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdio.h>
+#include <stdarg.h>
+#ifdef HAVE_LDAP_H
+#include <ldap.h>
+#endif
+
+#include "windef.h"
+#include "winbase.h"
+#include "winnls.h"
+#include "wine/winternl.h"
+
#include "winldap_private.h"
+#include "wldap32.h"
+#include "wine/debug.h"
#ifdef HAVE_LDAP
/* Should eventually be determined by the algorithm documented on MSDN. */
p++;
}
- res = HeapAlloc( GetProcessHeap(), 0, (i + 1) * sizeof(char *) );
- if (!res)
+ if (!(res = heap_alloc( (i + 1) * sizeof(char *) )))
{
- HeapFree( GetProcessHeap(), 0, str );
+ heap_free( str );
return NULL;
}
q = p;
i = 0;
-
+
while (*p)
{
if (p[1] != '\0')
res[i] = strdupU( q );
if (!res[i]) goto oom;
i++;
-
+
while (isspace( *p )) p++;
q = p;
}
}
res[i] = NULL;
- HeapFree( GetProcessHeap(), 0, str );
+ heap_free( str );
return res;
oom:
while (i > 0) strfreeU( res[--i] );
- HeapFree( GetProcessHeap(), 0, res );
- HeapFree( GetProcessHeap(), 0, str );
+ heap_free( res );
+ heap_free( str );
return NULL;
}
/* Determine if a URL starts with a known LDAP scheme */
-static int has_ldap_scheme( char *url )
+static BOOL has_ldap_scheme( char *url )
{
- if (!strncasecmp( url, "ldap://", 7 ) ||
- !strncasecmp( url, "ldaps://", 8 ) ||
- !strncasecmp( url, "ldapi://", 8 ) ||
- !strncasecmp( url, "cldap://", 8 )) return 1;
- return 0;
+ return !_strnicmp( url, "ldap://", 7 ) ||
+ !_strnicmp( url, "ldaps://", 8 ) ||
+ !_strnicmp( url, "ldapi://", 8 ) ||
+ !_strnicmp( url, "cldap://", 8 );
}
/* Flatten an array of hostnames into a space separated string of URLs.
}
size += (i - 1) * strlen( sep );
-
- res = HeapAlloc( GetProcessHeap(), 0, size + 1 );
- if (!res) return NULL;
+ if (!(res = heap_alloc( size + 1 ))) return NULL;
p = res;
for (v = hostnames; *v; v++)
}
#endif
+WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
+
+#ifdef HAVE_LDAP
+static LDAP *create_context( const char *url )
+{
+ LDAP *ld;
+ int version = LDAP_VERSION3;
+ if (ldap_initialize( &ld, url ) != LDAP_SUCCESS) return NULL;
+ ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version );
+ return ld;
+}
+#endif
+
/***********************************************************************
* cldap_openA (WLDAP32.@)
*
url = urlify_hostnames( "cldap://", hostnameU, portnumber );
if (!url) goto exit;
- ldap_initialize( &ld, url );
+ ld = create_context( url );
exit:
strfreeU( hostnameU );
*
* See ldap_initW.
*/
-WLDAP32_LDAP * CDECL ldap_initA( PCHAR hostname, ULONG portnumber )
+WLDAP32_LDAP * CDECL ldap_initA( const PCHAR hostname, ULONG portnumber )
{
#ifdef HAVE_LDAP
WLDAP32_LDAP *ld = NULL;
* to this function. The connection will not be made until the first
* LDAP function that needs it is called.
*/
-WLDAP32_LDAP * CDECL ldap_initW( PWCHAR hostname, ULONG portnumber )
+WLDAP32_LDAP * CDECL ldap_initW( const PWCHAR hostname, ULONG portnumber )
{
#ifdef HAVE_LDAP
LDAP *ld = NULL;
url = urlify_hostnames( "ldap://", hostnameU, portnumber );
if (!url) goto exit;
- ldap_initialize( &ld, url );
+ ld = create_context( url );
exit:
strfreeU( hostnameU );
url = urlify_hostnames( "ldap://", hostnameU, portnumber );
if (!url) goto exit;
- ldap_initialize( &ld, url );
+ ld = create_context( url );
exit:
strfreeU( hostnameU );