Instead of maintening your own LDAP connection for getting information about the users, maybe it could be nice to use an existing system service to get the LDAP information for you.
As entry point, you could look at that presentation about NSS, PAM and SSSD interactions: https://jhrozek.fedorapeople.org/presentations/linuxdays/linuxdays-2012-sssd.pdf