Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LDAP/AD Settings 4.0 Beta #3871

Closed
jmartins1 opened this issue Aug 21, 2017 · 15 comments
Closed

LDAP/AD Settings 4.0 Beta #3871

jmartins1 opened this issue Aug 21, 2017 · 15 comments
Labels
ldap ❓ not sure if bug This issue has not been confirmed as a bug yet

Comments

@jmartins1
Copy link

Using the same LDAP settings as in V3.6.6 (Working)
Attempted to use same LDAP settings in V4.0-beta (Broken)

capture

@rcarterv
Copy link

rcarterv commented Aug 21, 2017

I am experiencing the same issue. It looks like the test button uses the api route /api/v1/settings/ldaptest and results in a 401 Unauthorized return code.

In exploring further, it looks like the settings need to be saved prior to using the test button(?) so I added debug logging to the SettingsController and found this error when attempting to save the LDAP configuration:

development.DEBUG: {"slack_endpoint":["The slack endpoint format is invalid."], "slack_channel":["The slack channel format is invalid.]}

Interestingly enough, when I tried to setup a slack integration (to see if it would help me get LDAP working) I found this error:

development.DEBUG: {"ldap_server":["The ldap server format is invalid."]}  

@rcarterv
Copy link

Commenting out the 'slack' validation rules in the /app/Models/Setting.php file lets me save my LDAP settings:

    protected $rules = [
          "brand"     => 'required|min:1|numeric',
          "qr_text"         => 'max:31',
          "logo_img"        => 'mimes:jpeg,bmp,png,gif',
          "alert_email"   => 'email_array',
          "default_currency"   => 'required',
          "locale"   => 'required',
//          "slack_endpoint"   => 'url|required_with:slack_channel',
//          "slack_channel"   => 'regex:/(?<!\w)#\w+/|required_with:slack_endpoint',
//          "slack_botname"   => 'string|nullable',
          ...
          "ldap_server"   => 'sometimes|required_if:ldap_enabled,1|url',
          "ldap_uname"     => 'sometimes|required_if:ldap_enabled,1',
          "ldap_basedn"     => 'sometimes|required_if:ldap_enabled,1',
          "ldap_filter"     => 'sometimes|required_if:ldap_enabled,1',
          "ldap_username_field"     => 'sometimes|required_if:ldap_enabled,1',
          "ldap_fname_field"     => 'sometimes|required_if:ldap_enabled,1',
          "ldap_lname_field"     => 'sometimes|required_if:ldap_enabled,1',
          "ldap_auth_filter_query"     => 'sometimes|required_if:ldap_enabled,1',
          "ldap_version"     => 'sometimes|required_if:ldap_enabled,1',
          "thumbnail_max_h"     => 'numeric|max:500|min:25',
    ];

Now when I click the 'Test LDAP Connection' button I get a 500 Internal Server Error with no logs tied to it (I'm in debug mode).

In the LDAP Documentation it references this command that can be used to sync users that I tried:

php artisan snipeit:ldap-sync

Which produced:

[2017-08-21 17:15:59] development.ERROR: ErrorException: Trying to get property of non-object in /var/www/html/app/Http/Transformers/UsersTransformer.php:37
Stack trace:
#0 /var/www/html/app/Models/Ldap.php(242): App\Models\Ldap::bindAdminToLdap(Resource id #489)
#1 /var/www/html/app/Console/Commands/LdapSync.php(70): App\Models\Ldap::findLdapUsers()
#2 [internal function]: App\Console\Commands\LdapSync->handle()
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#6 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#7 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\Container\Container->call(Array)
#8 /var/www/html/vendor/symfony/console/Command/Command.php(264): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#9 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#10 /var/www/html/vendor/symfony/console/Application.php(874): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/html/vendor/symfony/console/Application.php(228): Symfony\Component\Console\Application->doRunCommand(Object(App\Console\Commands\LdapSync), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/html/vendor/symfony/console/Application.php(130): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 {main}  
error

I'm still trying to drill down to understand this better.

@snipe
Copy link
Owner

snipe commented Aug 22, 2017

@jmartins1 - can you be more specific than "broken"? Errors, logs, etc.

@rcarterv:

In exploring further, it looks like the settings need to be saved prior to using the test button(?)

That's correct

@jmartins1
Copy link
Author

jmartins1 commented Aug 22, 2017 via email

@jmartins1
Copy link
Author

jmartins1 commented Aug 22, 2017 via email

@snipe
Copy link
Owner

snipe commented Aug 22, 2017

@jmartins1 The information we need was in the issue template. Please see the getting help documentation for information on how to turn on debugging, find log files, etc. https://snipe-it.readme.io/docs/getting-help

@jmartins1
Copy link
Author

jmartins1 commented Aug 22, 2017 via email

@snipe
Copy link
Owner

snipe commented Aug 22, 2017

@rcarterv

[2017-08-21 17:15:59] development.ERROR: ErrorException: Trying to get property of non-object in /var/www/html/app/Http/Transformers/UsersTransformer.php:37

That error doesn't really make sense though. Line 37 is:

'department' => ($user->department) ? [
                    'id' => (int) $user->department->id,
                    'name'=> e($user->department->name)
                ]  : null,

That error implies that the user isn't an object, in which case it should trigger that error the first time we reference the user in that transformer.

@snipe
Copy link
Owner

snipe commented Aug 22, 2017

Can you do a fresh pull and see if today's changes fix anything? I can't reproduce this error at all on my end.

@jmartins1
Copy link
Author

jmartins1 commented Aug 22, 2017 via email

@snipe snipe added ❓ not sure if bug This issue has not been confirmed as a bug yet ldap labels Aug 22, 2017
@jmartins1
Copy link
Author

jmartins1 commented Aug 22, 2017 via email

@rcarterv
Copy link

I think a nice UI addition would be a message that indicates that the LDAP settings need to be saved before they can be tested.

Also, some additional logging around saving settings would be nice for troubleshooting..

@snipe
Copy link
Owner

snipe commented Aug 25, 2017

@rcarterv all of those are planned, but we have to ship v4 first.

@rcarterv
Copy link

Good to know- I'll wait for LDAP functionality post-4.0 release.

@rcarterv
Copy link

rcarterv commented Sep 6, 2017

LDAP functionality (minus the test button) now works for me as of 4.0-beta4. Thanks!

@snipe snipe closed this as completed Oct 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ldap ❓ not sure if bug This issue has not been confirmed as a bug yet
Projects
None yet
Development

No branches or pull requests

3 participants