Search code examples
python-ldap

python-ldap to get data from server 2003


when I test the following command in Centos

ldapsearch -v -d5 ldaps://192.168.0.254 -D "cn=xuqifeng" -w 'xuqifeng'

sys tell me:

ldap_initialize( <DEFAULT> )
ldap_create
ldap_sasl_bind
ldap_send_initial_request
ldap_new_connection 1 1 0
ldap_int_open_connection
ldap_connect_to_host: TCP localhost:389
ldap_new_socket: 3
ldap_prepare_socket: 3
ldap_connect_to_host: Trying ::1 389
ldap_pvt_connect: fd: 3 tm: -1 async: 0
ldap_close_socket: 3
ldap_new_socket: 3
ldap_prepare_socket: 3
ldap_connect_to_host: Trying 127.0.0.1:389
ldap_pvt_connect: fd: 3 tm: -1 async: 0
ldap_close_socket: 3
ldap_err2string
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)

OMG,Help.ps:System which host ip is 192.168.0.254 is Microsoft Server 2003.


Solution

  • You are not providing correct host parameter to ldapsearch. Use -H to achieve that

    ldapsearch -v -d5 -H ldaps://192.168.0.254 -D "cn=xuqifeng" -w 'xuqifeng'

    But this has nothing to do with python