[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
[ldap] Microsoft's LDAP api
Hi all,
I'm new to ldap and trying to brush up on my windows programming as well...
Anyway, anyone have experience with Microsoft's ldap api (wldap32) ?
My sample code follows...
The problems seem to be many... First off I get an access violation in the
ldap_set_option (this code came right out of the Microsoft MSDN), if I comment
this out the program does not connect to the server... Looking at the ld
structure the host is null... If I replace the ldap_init with an ldap_open it
connects, but the ldap_set_option still access violates...
Am I doing something wrong here or is this just a buggy api ? Just I give this
up and go to the Netscape sdk ? Are there better libraries out there ?
Thanks,
Victor
Environment :
NT 4.0 sp 3
VC++ 6.0
OpenLDAP 1.2 (on Solaris 2.6... working fine)
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows
headers
#include <windows.h>
#include <Winldap.h>
int main( void )
{
LDAP *ld = NULL;
ULONG version = LDAP_VERSION3;
// initialize the LDAP session
if ( ( ld = ldap_init( "tl-sun26", LDAP_PORT )) == NULL)
{
perror( "ldap_init" );
return (1);
}
// set options
if ( ( ldap_set_option( ld, LDAP_OPT_VERSION, &version )) != LDAP_SUCCESS)
{
ldap_perror( ld, "set_option" );
return (1);
}
// authenticate to the LDAP server
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS )
{
ldap_perror( ld, "bind" );
return (1);
}
ldap_unbind( ld );
return 0;
}