SHARE
    TWEET
    Krenair

    phpBB LDAP validate session patch

    Mar 15th, 2014
    247
    0
    Never
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    Diff 1.74 KB | None | 0 0
    1. diff --git a/phpBB/includes/auth/auth_ldap.php b/phpBB/includes/auth/auth_ldap.php
    2. index eebf147..1a4fd12 100644
    3. +++ b/phpBB/includes/auth/auth_ldap.php
    4. @@ -271,6 +271,52 @@ function login_ldap(&$username, &$password)
    5. );
    6. }
    7. +function validate_session_ldap($user_row)
    8. +{
    9. + global $config;
    10. + if (!@extension_loaded('ldap'))
    11. + {
    12. + return true;
    13. + }
    14. +
    15. + $config['ldap_port'] = (int) $config['ldap_port'];
    16. + if ($config['ldap_port'])
    17. + {
    18. + $ldap = @ldap_connect($config['ldap_server'], $config['ldap_port']);
    19. + }
    20. + else
    21. + {
    22. + $ldap = @ldap_connect($config['ldap_server']);
    23. + }
    24. +
    25. + if (!$ldap)
    26. + {
    27. + return true;
    28. + }
    29. +
    30. + ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
    31. + ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
    32. +
    33. + if ($config['ldap_user'] || $config['ldap_password'])
    34. + {
    35. + if (!@ldap_bind($ldap, htmlspecialchars_decode($config['ldap_user']), htmlspecialchars_decode($config['ldap_password'])))
    36. + {
    37. + return true;
    38. + }
    39. + }
    40. +
    41. + $search = @ldap_list(
    42. + $ldap,
    43. + htmlspecialchars_decode($config['ldap_base_dn']),
    44. + ldap_user_filter($user_row['username'])
    45. + );
    46. +
    47. + $ldap_result = @ldap_get_entries($ldap, $search);
    48. +
    49. + @ldap_close($ldap);
    50. + return is_array($ldap_result) && isset($ldap_result["count"]) && $ldap_result["count"] > 0;
    51. +}
    52. +
    53. /**
    54. * Generates a filter string for ldap_search to find a user
    55. *
    56. @@ -350,4 +396,4 @@ function acp_ldap(&$new)
    57. );
    58. }
    59. -?>
    60. \ No newline at end of file
    61. +?>
    Advertisement
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /