[Date Prev][Date Next] [Chronological] [Thread] [Top]

can't connect to OpenLDAP server from windows using windows API



hi, there

I'm new to LDAP. I installed OpenLDAP server on one linux machine and write
a small client application. The application works ok on Unix machine. But
when I use it on windows, it failed. Does someone can tell me what special
concern for a window client to access OpenLDAP server on Unix?

Thanks for help.

Jessica

/********************my application***********************/
#include <windows.h>
#include <winldap.h>
#include "Winber.h"
#include <stdio.h>

int main() {
    LDAP* handler = NULL;
    handler = ldap_init("192.168.0.14", 636);
    if(!handler) {
        fprintf(stderr, "Can't init the LDAP handler\n");
        return 1;
    }
    fprintf(stderr, "The handler is inited\n");

    int retval = 0;
    int numReturns = 10;
    retval = ldap_set_option(handler, LDAP_OPT_SIZELIMIT, (void*)
&numReturns);
    if(retval == LDAP_SUCCESS) fprintf(stderr, "set succeed\n");
    else {
        fprintf(stderr, "set failed, the retval is %d\n", retval);
        fprintf(stderr, "%s\n", ldap_err2string(retval));
        ldap_unbind(handler);
        return 1;
    }

    retval = ldap_simple_bind_s(handler,
"cn=Manager,dc=example,dc=com","secret");
    if(retval == LDAP_SUCCESS) fprintf(stderr, "bind succeed\n");
    else {
         fprintf(stderr, "bind failed, the retval is %d\n", retval);
        fprintf(stderr, "%s\n", ldap_err2string(retval));
        ldap_unbind(handler);
        return 1;
    }
    ....
}

/**********output***************/

The handler is inited
set succeed
bind failed, the retval is 81
Server Down
/*******************************/

/***********Server log************/
daemon: activity on 1 descriptors
daemon: new connection on 9
daemon: conn=4 fd=9 connection from IP=192.168.0.13:3499
(IP=192.168.0.14:636) accepted.
daemon: added 9r
daemon: activity on:
daemon: select: listen=6 active_threads=0 tvp=NULL
daemon: activity on 1 descriptors
daemon: activity on: 9r
daemon: read activity on 9
connection_get(9)
connection_get(9): got connid=4
connection_read(9): checking for input on id=4
ber_get_next
ldap_read: want=1, got=1
  0000:  80                                                 .
ldap_read: want=1, got=1
  0000:  6a                                                 j
ldap_read: want=106, got=106
  0000:  01 03 01 00 51 00 00 00  10 8f 80 01 80 00 03 80   ....Q...........
  0010:  00 01 81 00 01 81 00 03  82 00 01 00 00 04 00 00   ................
  0020:  05 00 00 0a 83 00 04 84  80 40 01 00 80 07 00 c0   .........@......
  0030:  03 00 80 00 00 09 06 00  40 00 00 64 00 00 62 00  
........@..d..b.
  0040:  00 03 00 00 06 83 00 04  84 28 40 02 00 80 04 00   .........(@.....
  0050:  80 00 00 13 00 00 12 00  00 63 88 ba ff ba b7 f7   .........c......
  0060:  eb 00 49 e7 86 f5 40 34  e0 8e                    
..I...@4..
ber_get_next: tag 0xffffff80 len 106 contents:
ber_dump: buf=0x080e2228 ptr=0x080e2228 end=0x080e2292 len=106
  0000:  01 03 01 00 51 00 00 00  10 8f 80 01 80 00 03 80   ....Q...........
  0010:  00 01 81 00 01 81 00 03  82 00 01 00 00 04 00 00   ................
  0020:  05 00 00 0a 83 00 04 84  80 40 01 00 80 07 00 c0   .........@......
  0030:  03 00 80 00 00 09 06 00  40 00 00 64 00 00 62 00  
........@..d..b.
  0040:  00 03 00 00 06 83 00 04  84 28 40 02 00 80 04 00   .........(@.....
  0050:  80 00 00 13 00 00 12 00  00 63 88 ba ff ba b7 f7   .........c......
  0060:  eb 00 49 e7 86 f5 40 34  e0 8e                    
..I...@4..
ber_get_next on fd 9 failed errno=0 (Success)
connection_read(9): input error=-2 id=4, closing.
connection_closing: readying conn=4 sd=9 for close
connection_close: conn=4 sd=9
daemon: removing 9
conn=-1 fd=9 closed
daemon: select: listen=6 active_threads=0 tvp=NULL
daemon: activity on 1 descriptors
daemon: select: listen=6 active_threads=0 tvp=NULL
/*******************************************************************/