I am writing a DLL that will access the LDAP C API and do some
searches in an LDAP.  My problem is that when I writ the code and
build a simple EXE in VC6, everything seems to work fine.  However,
when I put the same code in an ATL DLL, I get memory reference errors.
 Any help will be much appreciated.  Thanks in advance.  Below is the
code:

The error seems to occur on the following line:

if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) { 

I create a VB6 exe that calls this DLL and error that I get is that
some memory location could not read from memory location 0x000000000


Shahryar Khan

======================
// ldapAuthenticate.cpp : Implementation of CldapAuthenticate 
#include "stdafx.h" 
#include "Ldap_com2.h" 
#include "ldapAuthenticate.h" 
#include "examples.h" 
/////////////////////////////////////////////////////////////////////////////
// CldapAuthenticate 

HRESULT __stdcall CldapAuthenticate::Authenticate(BSTR ival,long*
retval)
{ 
        ULONG   ulres; 
        LDAP            *ld; 
        //LDAPMessage   *result; 
        //LDAPMessage   *e; 
        //BerElement    *ber; 
        //char          *a, *dn; 
        //char          **vals; 
        //int           i; 

        /* get a handle to an LDAP connection */ 
        if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) { 
                //perror( "ldap_init" ); 
                return E_FAIL; 
        } 
        
        ldap_simple_bind_s(ld,NULL,NULL); 

//THE ERROR OCCURS IN THE FOLLOWING LINE>>
        if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) { 
                //ldap_perror( ld, "ldap_simple_bind_s" ); 
                ldap_unbind(ld); 
                return E_FAIL; 
        } 
 
        ldap_unbind( ld ); 

        *retval = 12; 
        return S_OK; 
}

Reply via email to