Index: trunk/extensions/LdapAuthentication/LdapAuthentication.php |
— | — | @@ -1105,9 +1105,8 @@ |
1106 | 1106 | return $this->userInfo; |
1107 | 1107 | } |
1108 | 1108 | |
1109 | | - $entry = @ldap_read( $this->ldapconn, $this->userdn, "objectclass=*", array( '*', 'memberof' ) ); |
1110 | | - $userInfo = @ldap_get_entries( $this->ldapconn, $entry ); |
1111 | | - if ( $userInfo["count"] < 1 ) { |
| 1109 | + $userInfo = $this->getUserInfoStateless( $this->usernn ); |
| 1110 | + if ( is_null( $userInfo ) ) { |
1112 | 1111 | $this->fetchedUserInfo = false; |
1113 | 1112 | return; |
1114 | 1113 | } else { |
— | — | @@ -1116,6 +1115,32 @@ |
1117 | 1116 | } |
1118 | 1117 | } |
1119 | 1118 | |
| 1119 | + function getUserInfoStateless( $userdn ) { |
| 1120 | + // Don't fetch the same data more than once |
| 1121 | + // TODO: use memcached here |
| 1122 | + |
| 1123 | + $entry = @ldap_read( $this->ldapconn, $userdn, "objectclass=*", array( '*', 'memberof' ) ); |
| 1124 | + $userInfo = @ldap_get_entries( $this->ldapconn, $entry ); |
| 1125 | + if ( $userInfo["count"] < 1 ) { |
| 1126 | + return; |
| 1127 | + } else { |
| 1128 | + return $userInfo; |
| 1129 | + } |
| 1130 | + } |
| 1131 | + |
| 1132 | + function getSearchAttribute() { |
| 1133 | + global $wgLDAPSearchAttributes; |
| 1134 | + |
| 1135 | + // Return the search attribute configured, mainly for use in other |
| 1136 | + // extensions |
| 1137 | + // TODO: make function to pull any configuration item |
| 1138 | + if ( isset( $wgLDAPSearchAttributes[$_SESSION['wsDomain']] ) ) { |
| 1139 | + return $wgLDAPSearchAttributes[$_SESSION['wsDomain']]; |
| 1140 | + } else { |
| 1141 | + return ''; |
| 1142 | + } |
| 1143 | + } |
| 1144 | + |
1120 | 1145 | /** |
1121 | 1146 | * Retrieve user preferences from LDAP |
1122 | 1147 | * |