Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/phpBB/includes/auth/auth_ldap.php b/phpBB/includes/auth/auth_ldap.php
- index eebf147..1a4fd12 100644
- +++ b/phpBB/includes/auth/auth_ldap.php
- @@ -271,6 +271,52 @@ function login_ldap(&$username, &$password)
- );
- }
- +function validate_session_ldap($user_row)
- +{
- + global $config;
- + if (!@extension_loaded('ldap'))
- + {
- + return true;
- + }
- +
- + $config['ldap_port'] = (int) $config['ldap_port'];
- + if ($config['ldap_port'])
- + {
- + $ldap = @ldap_connect($config['ldap_server'], $config['ldap_port']);
- + }
- + else
- + {
- + $ldap = @ldap_connect($config['ldap_server']);
- + }
- +
- + if (!$ldap)
- + {
- + return true;
- + }
- +
- + ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
- + ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
- +
- + if ($config['ldap_user'] || $config['ldap_password'])
- + {
- + if (!@ldap_bind($ldap, htmlspecialchars_decode($config['ldap_user']), htmlspecialchars_decode($config['ldap_password'])))
- + {
- + return true;
- + }
- + }
- +
- + $search = @ldap_list(
- + $ldap,
- + htmlspecialchars_decode($config['ldap_base_dn']),
- + ldap_user_filter($user_row['username'])
- + );
- +
- + $ldap_result = @ldap_get_entries($ldap, $search);
- +
- + @ldap_close($ldap);
- + return is_array($ldap_result) && isset($ldap_result["count"]) && $ldap_result["count"] > 0;
- +}
- +
- /**
- * Generates a filter string for ldap_search to find a user
- *
- @@ -350,4 +396,4 @@ function acp_ldap(&$new)
- );
- }
- -?>
- \ No newline at end of file
- +?>
Advertisement
Add Comment
Please, Sign In to add comment