snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
11.21k stars 3.2k forks source link

Class 'Adldap\Adldap' not found #11103

Closed r-hardiman closed 2 years ago

r-hardiman commented 2 years ago

Debug mode

Describe the bug

When running the upgrade.php file to update from version 5.4 to version 6 I got multiple errors saying "Class 'Adldap\Adldap' not found", I have gotten round this by adding the following to the composer.json file and then running 'composer update' -

"adldap2/adldap2": "10.4.2"

However I am aware that when I do any git pull for updates in the future this change will revert and I will have the same issue, not sure if this is something I am doing wrong or something that needs to be added to the repo.

Reproduction steps

  1. Run update.php

Expected behavior

SnipeIt to update

Screenshots

No response

Snipe-IT Version

6.0.0

Operating System

Windows Server 2019

Web Server

IIS

PHP Version

7.4.29

Operating System

No response

Browser

No response

Version

No response

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

No response

Additional context

No response

snipe commented 2 years ago

We do not use the adldap package anymore, so it shouldn't be required in composer. We usually see this if some files are leftover from Snipe-IT that didn't get removed.

snipe commented 2 years ago

You shouldn't need the adldap dependency. You might try (after removing it from the composer.json) running composer install, composer dump-autoload and then php artisan cache:clear.

uberbrady commented 2 years ago

yeah, once you've pulled down the latest composer.json and the various other files, then when you do a composer install the adldap2 library should be removed.

What I suspect here is that during the 'git pull' process not all of your files are getting updated to the latest properly. Maybe you have some errors about 'local changes' or something? If you can show us the output of what you get when you run php upgrade.php we might be able to point you in the right directly.

r-hardiman commented 2 years ago

I've just ran php upgrade.php to upgrade to V6.0.1 and got the following output:

`E:\AuraAssets-New>php upgrade.php Skipping user check as it is not supported on Windows or Posix is not installed on this server.

WELCOME TO THE SNIPE-IT UPGRADER!

This script will attempt to:


STEP 1: Checking PHP requirements:

Current PHP version: (7.4.29) is at least 7.4.0 - continuing... FYI: The php.ini used by this PHP is: C:\Program Files\PHP\v7.4\php.ini

Checking Required PHP extensions...

√ bcmath is installed! √ curl is installed! √ fileinfo is installed! √ gd is installed! √ json is installed! √ ldap is installed! √ mbstring is installed! √ mysqli is installed! √ openssl is installed! √ PDO is installed! √ sodium is installed! √ tokenizer is installed! √ xml is installed! √ zip is installed!


STEP 2: Backing up database:

-- Starting backup... Dumping database aura_assets... Determining files to backup... Zipping 343 files and directories... Created zip containing 343 files and directories. Size is 6.32 MB Copying zip to disk named backup... Successfully copied zip to disk named backup. Backup completed!


STEP 3: Putting application into maintenance mode:

-- Application is now in maintenance mode.


STEP 4: Pulling latest from Git (master branch):

Git is installed. remote: Enumerating objects: 85, done. remote: Counting objects: 100% (85/85), done. remote: Compressing objects: 100% (39/39), done. remote: Total 85 (delta 48), reused 71 (delta 45), pack-reused 0 Unpacking objects: 100% (85/85), 104.63 KiB | 227.00 KiB/s, done. From https://github.com/snipe/snipe-it 1c32dcae9..15a1db480 master -> origin/master 1c32dcae9..15a1db480 develop -> origin/develop


Step 5: Cleaning up old cached files:

√ No bootstrap/cache/compiled.php, so nothing to delete. √ Deleting bootstrap/cache/services.php. It is no longer used. √ Deleting bootstrap/cache/config.php. It is no longer used.

-- Configuration cache cleared! -- Application cache cleared! -- Route cache cleared! -- Compiled views cleared!


Step 6: Updating composer dependencies: (This may take a moment.)

-- We couldn't find a local composer.phar. No worries, trying globally.

Warning: Ambiguous class resolution, "ReCreateLicensesTable" was found in both "E:/AuraAssets-New/database/migrations/2013_11_25_013244_create_licenses_table.php" and "E:/AuraAssets-New/database/migrations/2013_11_25_013244_recreate_licenses_table.php", the first will be used.

Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover --ansi @php artisan vendor:publish --force --tag=livewire:assets --ansi Installing dependencies from lock file Verifying lock file contents can be installed on current platform. Package operations: 0 installs, 1 update, 34 removals

  • Syncing aws/aws-sdk-php (3.222.13) into cache
  • Removing tightenco/collect (v8.83.12)
  • Removing theseer/tokenizer (1.2.1)
  • Removing symfony/yaml (v5.4.3)
  • Removing symfony/dom-crawler (v4.4.39)
  • Removing sebastian/version (3.0.2)
  • Removing sebastian/type (3.0.0)
  • Removing sebastian/resource-operations (3.0.3)
  • Removing sebastian/object-reflector (2.0.4)
  • Removing sebastian/object-enumerator (4.0.4)
  • Removing sebastian/lines-of-code (1.0.3)
  • Removing sebastian/global-state (5.0.5)
  • Removing sebastian/environment (5.1.4)
  • Removing sebastian/complexity (2.0.2)
  • Removing sebastian/code-unit-reverse-lookup (2.0.3)
  • Removing sebastian/code-unit (1.0.8)
  • Removing sebastian/cli-parser (1.0.1)
  • Removing phpunit/phpunit (9.5.20)
  • Removing phpunit/php-token-stream (3.1.3)
  • Removing phpunit/php-timer (5.0.3)
  • Removing phpunit/php-text-template (2.0.4)
  • Removing phpunit/php-invoker (3.1.1)
  • Removing phpunit/php-file-iterator (3.0.6)
  • Removing phpunit/php-code-coverage (9.2.15)
  • Removing php-webdriver/webdriver (1.12.1)
  • Removing phar-io/version (3.2.1)
  • Removing phar-io/manifest (2.0.3)
  • Removing overtrue/phplint (3.0.6)
  • Removing n98/junit-xml (1.1.0)
  • Removing myclabs/deep-copy (1.11.0)
  • Removing mockery/mockery (1.5.0)
  • Removing laravel/dusk (v6.24.0)
  • Removing hamcrest/hamcrest-php (v2.0.1)
  • Removing fakerphp/faker (v1.19.0)
  • Removing adldap2/adldap2 (v10.4.2)
  • Upgrading aws/aws-sdk-php (3.222.12 => 3.222.13): Checking out 007ddbbded from cache 0/24 [>---------------------------] 0% 9/24 [==========>-----------------] 37% 17/24 [===================>--------] 70% 20/24 [=======================>----] 83% 22/24 [=========================>--] 91% 24/24 [============================] 100% Package doctrine/reflection is abandoned, you should avoid using it. Use roave/better-reflection instead. Package patchwork/utf8 is abandoned, you should avoid using it. Use symfony/polyfill-mbstring or symfony/string instead.Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead. Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested. Generating optimized autoload files Warning: Ambiguous class resolution, "ReCreateLicensesTable" was found in both "E:/AuraAssets-New/database/migrations/2013_11_25_013244_create_licenses_table.php" and "E:/AuraAssets-New/database/migrations/2013_11_25_013244_recreate_licenses_table.php", the first will be used. Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover --ansi Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1 Generating optimized autoload files Discovered Package: arietimmerman/laravel-scim-server Discovered Package: barryvdh/laravel-debugbar Discovered Package: barryvdh/laravel-dompdf Discovered Package: eduardokum/laravel-mail-auto-embed Discovered Package: facade/ignition Discovered Package: fideloper/proxy Discovered Package: fruitcake/laravel-cors Discovered Package: intervention/image Discovered Package: laravel/dusk Discovered Package: laravel/passport Discovered Package: laravel/slack-notification-channel Discovered Package: laravel/tinker Discovered Package: laravel/ui Discovered Package: laravelcollective/html Discovered Package: livewire/livewire Discovered Package: maatwebsite/excel Discovered Package: mediconesystems/livewire-datatables Discovered Package: nesbot/carbon Discovered Package: nunomaduro/collision Discovered Package: pragmarx/google2fa-laravel Discovered Package: spatie/laravel-backup Discovered Package: unicodeveloper/laravel-password Package manifest generated successfully. Copied Directory [\vendor\livewire\livewire\dist] To [\public\vendor\livewire] Publishing complete. Generated optimized autoload files containing 10362 classes

Error

Class 'Adldap\Adldap' not found

at E:\AuraAssets-New\app\Services\LdapAd.php:100 96▕ sets up an 'account_suffix' of '@'.$this->ldapSettings['ad_domain'] IF the user has 97▕ $this->ldapSettings['ad_append_domain'] enabled. 98▕ That code in ldapLogin gets simplified, in exchange for putting all the weirdness here only. 99▕ */ ➜ 100▕ $this->ldap = new Adldap(); 101▕ $this->ldap->addProvider($this->ldapConfig); 102▕ return true; 103▕ } 104▕ return false;

1 E:\AuraAssets-New\app\Services\LdapAd.php:108 App\Services\LdapAd::init()

2 [internal]:0 App\Services\LdapAd::__construct()

Whoops\Exception\ErrorException

Module 'openssl' already loaded

1 E:\AuraAssets-New\vendor\filp\whoops\src\Whoops\Run.php:486 Whoops\Run::handleError()

2 [internal]:0 Whoops\Run::handleShutdown()

Step 7: Migrating database:

Error

Class 'Adldap\Adldap' not found

at E:\AuraAssets-New\app\Services\LdapAd.php:100 96▕ sets up an 'account_suffix' of '@'.$this->ldapSettings['ad_domain'] IF the user has 97▕ $this->ldapSettings['ad_append_domain'] enabled. 98▕ That code in ldapLogin gets simplified, in exchange for putting all the weirdness here only. 99▕ */ ➜ 100▕ $this->ldap = new Adldap(); 101▕ $this->ldap->addProvider($this->ldapConfig); 102▕ return true; 103▕ } 104▕ return false;

1 E:\AuraAssets-New\app\Services\LdapAd.php:108 App\Services\LdapAd::init()

2 [internal]:0 App\Services\LdapAd::__construct()

Whoops\Exception\ErrorException

Module 'openssl' already loaded

1 E:\AuraAssets-New\vendor\filp\whoops\src\Whoops\Run.php:486 Whoops\Run::handleError()

2 [internal]:0 Whoops\Run::handleShutdown()


Step 8: Checking for OAuth keys:

√ OAuth keys detected. Skipping passport install.


Step 9: Taking application out of maintenance mode:

-- Error

Class 'Adldap\Adldap' not found

at E:\AuraAssets-New\app\Services\LdapAd.php:100 96▕ sets up an 'account_suffix' of '@'.$this->ldapSettings['ad_domain'] IF the user has 97▕ $this->ldapSettings['ad_append_domain'] enabled. 98▕ That code in ldapLogin gets simplified, in exchange for putting all the weirdness here only. 99▕ */ ➜ 100▕ $this->ldap = new Adldap(); 101▕ $this->ldap->addProvider($this->ldapConfig); 102▕ return true; 103▕ } 104▕ return false;

1 E:\AuraAssets-New\app\Services\LdapAd.php:108 App\Services\LdapAd::init()

2 [internal]:0 App\Services\LdapAd::__construct()

Whoops\Exception\ErrorException

Module 'openssl' already loaded

1 E:\AuraAssets-New\vendor\filp\whoops\src\Whoops\Run.php:486 Whoops\Run::handleError()

2 [internal]:0 Whoops\Run::handleShutdown()

---------------------- FINISHED! ----------------------- All done! Clear your browser cookies and re-login to use your upgraded Snipe-IT! --------------------------------------------------------`

GitHub
GitHub - snipe/snipe-it: A free open source IT asset/license management system
A free open source IT asset/license management system - GitHub - snipe/snipe-it: A free open source IT asset/license management system
uberbrady commented 2 years ago

It doesn't look like it's run 'clean' - there are files it should be deleting, that, for some reason, it is not.

What do you get if you say git status in your directory there? I suspect it's going to say there are some files it's not expecting to see...

snipe commented 2 years ago

You can try nuking your vendors directory and reinstalling composer dependencies by deleting the `vendor1 directory and installing composer manually.

git pull
composer install --no-dev --prefer-source
composer dump-autoload
php artisan cache:clear 
php artisan config:clear
php artisan route:clear
php artisan debugbar:clear
php artisan event:clear
php artisan view:clear
php artisan clear-compiled
php artisan migrate

And let us know the output of each step.

r-hardiman commented 2 years ago

It doesn't look like it's run 'clean' - there are files it should be deleting, that, for some reason, it is not.

What do you get if you say git status in your directory there? I suspect it's going to say there are some files it's not expecting to see...

This is the output I get when I run git status -

Refresh index: 100% (6348/6348), done.
On branch master
Your branch is up to date with "origin/master".

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   composer.json
        modified:   composer.lock
        modified:   public/web.config

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .env.old
        app/Console/Commands/LdapSyncNg.php
        app/Providers/LdapServiceProvider.php
        app/Services/LdapAd.php
        app/Services/LdapAdConfiguration.php
        c3.php
        codeception.yml
        database/factories/ComponentsFactory.php
        database/factories/CustomFieldsFactory.php
        database/factories/DepartmentsFactory.php
        database/factories/ModelFactory.php
        database/migrations/2013_11_15_190357_create_licenses_table.php
        database/migrations/2013_11_25_013244_create_licenses_table.php
        database/seeds/
        public/css/fonts/FontAwesome.otf
        public/css/fonts/fontawesome-webfont.eot
        public/css/fonts/fontawesome-webfont.svg
        public/css/fonts/fontawesome-webfont.ttf
        public/css/fonts/fontawesome-webfont.woff
        public/css/fonts/fontawesome-webfont.woff2
        public/js/snipeit.js
        resources/assets/css/font-awesome/font-awesome.css
        resources/assets/css/font-awesome/font-awesome.min.css
        resources/assets/css/fonts/FontAwesome.otf
        resources/assets/css/fonts/fontawesome-webfont.eot
        resources/assets/css/fonts/fontawesome-webfont.svg
        resources/assets/css/fonts/fontawesome-webfont.ttf
        resources/assets/css/fonts/fontawesome-webfont.woff
        resources/assets/css/fonts/fontawesome-webfont.woff2
        resources/assets/js/components/forms/
        tests/TODO.testing
        tests/Unit/DepartmentTest.php
        tests/Unit/ManufacturerTest.php
        tests/Unit/SupplierTest.php

no changes added to commit (use "git add" and/or "git commit -a")
uberbrady commented 2 years ago

Yup, you've definitely got some stale files, and some locally-modified files - which are going to give you a bad time. (The public/web.config one might be OK? Depends on what you put in there).

Of course, as in all cases, you should probably do backup/snapshot/image first before you go mucking around here.

Once you've done that ...

You should be able to try git stash (which may yell at you about your name and some other stuff first) to make those 'modified' files get put away into a 'stash'. You may actually want the web.config changes you might have made, so I'd grab a copy of that first before you start messing with stuff.

As for the untracked files, you can just delete them. (Feel free to back them up somewhere first if you want to be careful - though hopefully you will have just imaged the server, so you won't need to).

Once you have everything cleaned up, a final composer install should remove any remaining references to that library we no longer use.

snipe commented 2 years ago

Hi there - We haven't heard back in a bit, so I'm going to close this ticket for now, but will re-open it if you're still having issues.

hackerman-hacking