global variable name causing functionality problems
| Project: | LDAP integration |
| Version: | 5.x-1.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | kreaper |
| Status: | closed |
Please see if this makes sense:
The ldapauth.module uses a global variable name called "ldap" to instantiate new LDAP objects. It also happens that the ldapdata module also uses the same global variable name "ldap".
In ldapauth.module, the function _ldapauth_save_user invokes the hook user_load and later on uses the global variable $ldap values to save ldap_config info to the user object. However, user_load invokes ldapdata.module as it provides that hook, which over rides the values in the global $ldap object.
This problem is visible in the following environment:
- Multiple LDAP Server Configs are in place and enabled
- User account is not found in the first config but in the later configs
This will cause the global $ldap object to lose its correct server info and get reset in the ldapdata.module.
FIX:
- Follow good coding practices and rename the global variable to module-specific variable. (i.e. Rename
$ldapto$ldapauth_ldap
I will provide a patch fix and I wanted to post the info so that others can comment and agree/disagree.
kreaper

#1
ldapdata.module.patch attached
#2
ldapauth.module.patch attached
#3
ldapgroups.module.patch
#4
Committing to HEAD