Our current solution is using a project that seems very close to dead. https://github.com/pear/Net_LDAP2
Investigate migrating to something like https://github.com/symfony/ldap
First step is to remove the code from Net_LDAP2 that copied into our repository and use the PHP library version. This will allow us to remove around 9,000+ lines of code.
Then work on moving to symfony/ldap after that.