l_ldap_whoami_s() is missing the check if (not_valid(self)) return NULL; This leads to a segfault when whoami_s() is called after unbind().
The bug was originally reported by Florent Xicluna https://github.com/pyldap/pyldap/issues/29
I've developed a fix with unit test, https://github.com/pyldap/pyldap/pull/30
fix will be released in 2.4.26