ldap_search_s - Unhandled exception at 0x77148705 Access violation reading location 0xcccccccc

Last post 09-18-2009 4:20 AM by ryuroden. 0 replies.

Sort Posts:

  • ldap_search_s - Unhandled exception at 0x77148705 Access violation reading location 0xcccccccc

    09-18-2009, 4:20 AM
    • Member
      point Member
    • ryuroden
    • Member since 09-18-2009, 4:07 AM
    • Posts 1

    Hi all

    I have an Unhanled Exception when using ldap_search_s :

    1. I used VC++ 2008 , winldap.h , Wldap32.lib

    2. My code :

        PCHAR hostName = Settings::LdapHost;
        LDAP* pLdapConnection = NULL;
        ULONG version = LDAP_VERSION3;
        ULONG numReturns = 10;
        ULONG lRtn = 0;

       
        pLdapConnection = ldap_init (hostName, Settings::LdapPort);
       
        if (pLdapConnection == NULL)
        {
            ldap_unbind(pLdapConnection);
            return -1;
        }
       
        lRtn = ldap_set_option (
                        pLdapConnection,           // Session handle
                        LDAP_OPT_PROTOCOL_VERSION, // Option
                        (void*) &version);         // Option value

        if(lRtn != LDAP_SUCCESS)
        {
            ldap_unbind(pLdapConnection);
            return -1;
        }

      
        lRtn = ldap_connect (pLdapConnection, NULL);
       
        if(lRtn != LDAP_SUCCESS)
        {
            ldap_unbind(pLdapConnection);
            return -1;
        }
       
       
        lRtn = ldap_simple_bind_s (pLdapConnection, pUserName, pPassword);

        if(lRtn != LDAP_SUCCESS)
        {
            printf("ldap_bind_s failed with 0x%lx.\n",lRtn);
            ldap_unbind(pLdapConnection);
            return -1;
        }
         
        ULONG errorCode = LDAP_SUCCESS;
        LDAPMessage* pSearchResult = 0;
        PCHAR pMyFilter = "(&(objectClass=*))";
        PCHAR pMyAttributes[2];
        pMyAttributes[0] = "cn";
        pMyAttributes[1] = "uid";
       
        errorCode = ldap_search_s (
                        pLdapConnection,                        // Session handle
                        "ou=manager,dc=com,dc=vn",              // DN to start search    pMyDN
                        LDAP_SCOPE_SUBTREE,                        // Scope
                        pMyFilter,                                // Filter
                        pMyAttributes,                            // Retrieve list of attributes
                        0,                                        // Get both attributes and values
                        &pSearchResult);                        // [out] Search results



    I got the Exception "Unhandled exception at 0x77148705 in LdapTest.exe: 0xC0000005: Access violation reading location 0xcccccccc " at line errorCode = ldap_search_s . Even I passed correct userName & Password, and I ran this test succesfully in C# with DirectoryEntry & DirectorySearcher

    Anyone who have experience, please help me. Many thanks!

Page 1 of 1 (1 items)