BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
15.36k stars 1.92k forks source link

Sometimes LDAPS connection dont work to AD server #1996

Closed kevinrode closed 3 years ago

kevinrode commented 4 years ago

Describe the bug Sometimes I get this error message on login: An unknown error occurred

Note: This problems only occure when I am using LDAPS on LDAP connection everything works fine

After i enabled the debug mode I get followign stacktrace (Changed user and pass):

` [2020-04-02 14:41:36] production.ERROR: ldap_bind(): Unable to bind to server: Can't contact LDAP server {"exception":"[object] (ErrorException(code: 0): ldap_bind(): Unable to bind to server: Can't contact LDAP server at /var/www/BookSt ack/app/Auth/Access/Ldap.php:93) [stacktrace]

0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'ldap_bind(): Un...', '/var/www/BookSt...', 93, Array)

1 /var/www/BookStack/app/Auth/Access/Ldap.php(93): ldap_bind(Resource id #558, 'syncuser@syncdomain...', 'xxxxxxxxx')

2 /var/www/BookStack/app/Auth/Access/LdapService.php(165): BookStack\Auth\Access\Ldap->bind(Resource id #558, 'syncuser@syncdomain...', 'xxxxxxxxx')

3 /var/www/BookStack/app/Auth/Access/LdapService.php(46): BookStack\Auth\Access\LdapService->bindSystemUser(Resource id #558)

4 /var/www/BookStack/app/Auth/Access/LdapService.php(80): BookStack\Auth\Access\LdapService->getUserWithAttributes('rodekev', Array)

5 /var/www/BookStack/app/Auth/Access/Guards/LdapSessionGuard.php(71): BookStack\Auth\Access\LdapService->getUserDetails('rodekev')

6 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php(82): BookStack\Auth\Access\Guards\LdapSessionGuard->attempt(Array, false)

7 /var/www/BookStack/app/Http/Controllers/Auth/LoginController.php(113): BookStack\Http\Controllers\Auth\LoginController->attemptLogin(Object(BookStack\Http\Request))

8 [internal function]: BookStack\Http\Controllers\Auth\LoginController->login(Object(BookStack\Http\Request))

9 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)

10 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('login', Array)

11 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(BookStack\Http\Controllers\Auth\LoginController), 'login')

12 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\Routing\Route->runController()

13 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Routing/Router.php(681): Illuminate\Routing\Route->run()

14 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(BookStack\Http\Request))

15 /var/www/BookStack/app/Http/Middleware/CheckGuard.php(25): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

16 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): BookStack\Http\Middleware\CheckGuard->handle(Object(BookStack\Http\Request), Object(Closure), 'standard', 'ldap')

17 /var/www/BookStack/app/Http/Middleware/RedirectIfAuthenticated.php(40): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

18 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): BookStack\Http\Middleware\RedirectIfAuthenticated->handle(Object(BookStack\Http\Request), Object(Closure))

19 /var/www/BookStack/app/Http/Middleware/GlobalViewData.php(25): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

20 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): BookStack\Http\Middleware\GlobalViewData->handle(Object(BookStack\Http\Request), Object(Closure))

21 /var/www/BookStack/app/Http/Middleware/Localization.php(76): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

22 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): BookStack\Http\Middleware\Localization->handle(Object(BookStack\Http\Request), Object(Closure))

23 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(76): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

24 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(BookStack\Http\Request), Object(Closure))

25 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

26 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(BookStack\Http\Request), Object(Closure))

27 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

28 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(BookStack\Http\Request), Object(Closure))

29 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(56): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

30 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Session\Middleware\StartSession->handle(Object(BookStack\Http\Request), Object(Closure))

31 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

32 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(BookStack\Http\Request), Object(Closure))

33 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

34 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(BookStack\Http\Request), Object(Closure))

35 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

36 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Routing/Router.php(683): Illuminate\Pipeline\Pipeline->then(Object(Closure))

37 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(BookStack\Http\Request))

38 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Routing/Router.php(624): Illuminate\Routing\Router->runRoute(Object(BookStack\Http\Request), Object(Illuminate\Routing\Route))

39 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Routing/Router.php(613): Illuminate\Routing\Router->dispatchToRoute(Object(BookStack\Http\Request))

40 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(170): Illuminate\Routing\Router->dispatch(Object(BookStack\Http\Request))

41 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(BookStack\Http\Request))

42 /var/www/BookStack/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(58): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

43 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(BookStack\Http\Request), Object(Closure))

44 /var/www/BookStack/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

45 /var/www/BookStack/app/Http/Middleware/TrustProxies.php(39): Fideloper\Proxy\TrustProxies->handle(Object(BookStack\Http\Request), Object(Closure))

46 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): BookStack\Http\Middleware\TrustProxies->handle(Object(BookStack\Http\Request), Object(Closure))

47 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

48 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(BookStack\Http\Request), Object(Closure))

49 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

50 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(BookStack\Http\Request), Object(Closure))

51 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

52 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(BookStack\Http\Request), Object(Closure))

53 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))

54 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\Pipeline\Pipeline->then(Object(Closure))

55 /var/www/BookStack/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(BookStack\Http\Request))

56 /var/www/BookStack/public/index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(BookStack\Http\Request))

57 {main}

"} `

Steps To Reproduce Steps to reproduce the behavior:

  1. Go to login page and insert the login credentials
  2. Click on login
  3. Get the error message like described above
  4. After I hit 2-3 times F5 the login works. Sometimes the login also works on the first try

Expected behavior Logged in

Screenshots If applicable, add screenshots to help explain your problem.

Your Configuration:

Additional context .env LDAP config: AUTH_METHOD=ldap LDAP_SERVER=ldaps://adserver.mydomain.com:636 LDAP_BASE_DN=OU=USERS,DC=syncdomain,DC=com LDAP_DN=syncuser@syncdomain.com LDAP_PASS=xxxxxxxxx LDAP_USER_FILTER=(&(sAMAccountName=${user})) LDAP_VERSION=3 LDAP_EMAIL_ATTRIBUTE=mail LDAP_USER_TO_GROUPS=true LDAP_GROUP_ATTRIBUTE="memberOf" LDAP_REMOVE_FROM_GROUPS=true LDAP_TLS_INSECURE=true

If you need any more infos let me know. Hope you can help and thank you in advance.

Reference to: #1069, #1220

MKCPC commented 4 years ago

I started experiencing a similar issue on my install today too however even when refreshing several times the authentication will not complete. The only way to resolve has been to fall back to LDAP rather than LDAPS as mentioned in #1220

IntelligentesTierMaulApollo13 commented 3 years ago

I've got the exact same problem with version 0.30.4 and a Samba4 AD DC. The first try to login fails reproducible but then either by hitting F5 or entering the same credentials again I am able to login. Is there anything I can do to help solve this issue?

Edit: Ok, I think, Samba4 has some kind of connection limit. I think in my case my systems established too many connections to the Samba4 server and thus before a new connection could be established, another needed to be cancelled. A reboot helped get rid of the problem...

ssddanbrown commented 3 years ago

Since the last comment on this issue is relatively old I'm going to close this. If the issue remains and is something you still require to be fixed please open a new issue, referencing this one.