*/
#include "config.h"
-
#include "wine/port.h"
-#include "wine/debug.h"
#include <stdio.h>
#include <stdarg.h>
+#ifdef HAVE_LDAP_H
+#include <ldap.h>
+#endif
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
-
-#ifdef HAVE_LDAP_H
-#include <ldap.h>
-#endif
+#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.
- * Prepend a given scheme and append a given portnumber to each hostname
+ * Prepend a given scheme and append a given port number to each hostname
* if necessary.
*/
static char *join_hostnames( const char *scheme, char **hostnames, ULONG portnumber )
}
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++)
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.@)
*
*
* PARAMS
* hostname [I] Name of the host to connect to.
- * portnumber [I] Portnumber to use.
+ * portnumber [I] Port number to use.
*
* RETURNS
* Success: Pointer to an LDAP context.
* The hostname string can be a space separated string of hostnames,
* in which case the LDAP runtime will try to connect to the hosts
* in order, until a connection can be made. A hostname may have a
- * trailing portnumber (separated from the hostname by a ':'), which
- * will take precedence over the portnumber supplied as a parameter
+ * trailing port number (separated from the hostname by a ':'), which
+ * will take precedence over the port number supplied as a parameter
* to this function.
*/
WLDAP32_LDAP * CDECL cldap_openW( PWCHAR hostname, ULONG portnumber )
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;
*
* PARAMS
* hostname [I] Name of the host to connect to.
- * portnumber [I] Portnumber to use.
+ * portnumber [I] Port number to use.
*
* RETURNS
* Success: Pointer to an LDAP context.
* The hostname string can be a space separated string of hostnames,
* in which case the LDAP runtime will try to connect to the hosts
* in order, until a connection can be made. A hostname may have a
- * trailing portnumber (separated from the hostname by a ':'), which
- * will take precedence over the portnumber supplied as a parameter
+ * trailing port number (separated from the hostname by a ':'), which
+ * will take precedence over the port number supplied as a parameter
* 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 );
*
* PARAMS
* hostname [I] Name of the host to connect to.
- * portnumber [I] Portnumber to use.
+ * portnumber [I] Port number to use.
*
* RETURNS
* Success: Pointer to an LDAP context.
* The hostname string can be a space separated string of hostnames,
* in which case the LDAP runtime will try to connect to the hosts
* in order, until a connection can be made. A hostname may have a
- * trailing portnumber (separated from the hostname by a ':'), which
- * will take precedence over the portnumber supplied as a parameter
+ * trailing port number (separated from the hostname by a ':'), which
+ * will take precedence over the port number supplied as a parameter
* to this function.
*/
WLDAP32_LDAP * CDECL ldap_openW( PWCHAR hostname, ULONG portnumber )
url = urlify_hostnames( "ldap://", hostnameU, portnumber );
if (!url) goto exit;
- ldap_initialize( &ld, url );
+ ld = create_context( url );
exit:
strfreeU( hostnameU );
*
* PARAMS
* hostname [I] Name of the host to connect to.
- * portnumber [I] Portnumber to use.
+ * portnumber [I] Port number to use.
* secure [I] Ask the server to create an SSL connection.
*
* RETURNS
* The hostname string can be a space separated string of hostnames,
* in which case the LDAP runtime will try to connect to the hosts
* in order, until a connection can be made. A hostname may have a
- * trailing portnumber (separated from the hostname by a ':'), which
- * will take precedence over the portnumber supplied as a parameter
+ * trailing port number (separated from the hostname by a ':'), which
+ * will take precedence over the port number supplied as a parameter
* to this function. The connection will not be made until the first
* LDAP function that needs it is called.
*/