if (rc != LDAP_SUCCESS) {
ERROR("openldap plugin: ldap_initialize failed: %s", ldap_err2string(rc));
st->state = 0;
- ldap_unbind_ext_s(ld, NULL, NULL);
+ if (ld != NULL)
+ ldap_unbind_ext_s(ld, NULL, NULL);
return (-1);
}
ERROR("openldap plugin: Failed to start tls on %s: %s", st->url,
ldap_err2string(rc));
st->state = 0;
- ldap_unbind_ext_s(st->ld, NULL, NULL);
+ if (st->ld != NULL)
+ ldap_unbind_ext_s(st->ld, NULL, NULL);
return (-1);
}
}
ERROR("openldap plugin: Failed to bind to %s: %s", st->url,
ldap_err2string(rc));
st->state = 0;
- ldap_unbind_ext_s(st->ld, NULL, NULL);
+ if (st->ld != NULL)
+ ldap_unbind_ext_s(st->ld, NULL, NULL);
return (-1);
} else {
DEBUG("openldap plugin: Successfully connected to %s", st->url);
ERROR("openldap plugin: Failed to execute search: %s", ldap_err2string(rc));
ldap_msgfree(result);
st->state = 0;
- ldap_unbind_ext_s(st->ld, NULL, NULL);
+ if (st->ld != NULL)
+ ldap_unbind_ext_s(st->ld, NULL, NULL);
return (-1);
}