Following a patch that I proposed for 1.2.x to address some LDAP issues (see bug #12167), David commited the changes, and finding some conflicts trying to port it to 1.3.x, asked me if I could help with that.
In particular, he pointed out that $g_ldap_port seems to be deprecated and I'm a bit confused by this... Looking at the revision history where this variable was added/removed, I find the following commits:
1. On 2008-05-03 in 46f632602d31088fe74659cbb6a110496ddf5cf9 (after 1.2.0a1), Paul Richards wrote "LDAP port is ignored when using an URL for LDAP connection - as our example uses this format, remove the port" - I assume this is what Paul means by ldap_port being obsolete (see #3 below)
2. On 2009-07-06 in 1fc901f9b40dd09e7d6ccabfb907a70fb1660d65 (after 1.2.0rc1), Victor Boctor added the variable back to config_defaults_inc.php (and from there, it remains to-date in 1.2.x branch)
3. On 2009-12-23 in commit c207d0452631f6f5648e1813c807bce4873acc20 (1.3.x), Paul Richards wrote "ldap_port was obsoleted in 1.2.0a1... see previous commit message/php docs"
I would appreciate if you guys (Paul, Victor ?) could clarify the situation - as it stands, my change (commited by David) 8f23dcc46eb78cdd05ae7755bfffac0d24fce6bc is aligned with 1.2.x, but not with Paul's opinion that ldap_port should be obsolete.
It does not really matter to me whether ldap_port is obsoleted or not (since it's easy enough to specify the port as part of the URI), but currently in 1.2.x branch it is a valid option and so the code is not consistent with 1.3.x. Furthermore, the documentation is not up-to-date (admin guide, configuration section).