DirectoryTree / LdapRecord-Laravel

Multi-domain LDAP Authentication & Management for Laravel.
https://ldaprecord.com/docs/laravel/v3
MIT License
496 stars 52 forks source link

[Support] Why do I get an error in Docker when running Command for LDAP #449

Closed hekler91 closed 2 years ago

hekler91 commented 2 years ago

Hello

I'm trying to run my LDAP Command on Docker, unfortunately I get this error:

Use of undefined constant LDAP_ESCAPE_FILTER - assumed 'LDAP_ESCAPE_FILTER' (this will throw an Error in a future version of PHP)

at vendor/directorytree/ldaprecord/src/Models/Attributes/EscapedValue.php:117 113▕ @return $this 114▕ / 115▕ public function both() 116▕ { ➜ 117▕ $this->flags = LDAP_ESCAPE_FILTER + LDAP_ESCAPE_DN; 118▕ 119▕ return $this; 120▕ } 121▕ }

vendor frames app/Console/Commands/SyncLdap.php:21 LdapRecord\Models\Model::all() vendor frames 22 artisan:37

I put the following in the Docker file:

FROM php:7.4-cli

COPY . /usr/src/enterprise-service-bus

WORKDIR /usr/src/enterprise-service-bus

Configure LDAP.

FROM php:7.4.9-fpm-alpine3.12

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/

Install PHP extensions

RUN install-php-extensions ldap and then started the installation with 'docker build -t getting-started.

Do I need to configure anything else for LDAP and how to solve this problem?

Thanks to everyone for their help.

Environment:

stevebauman commented 2 years ago

Hi @hekler91,

This means that your PHP installation in the docker container does not have the LDAP extension enabled. Make sure it's enabled, and this error will go away.

hekler91 commented 2 years ago

Hi Steve I think I activated it in Docker. This is my Dockerfile:

FROM php:8.0.2-fpm-alpine
COPY . /usr/src/enterprise-service-bus
WORKDIR /usr/src/enterprise-service-bus
#RUN pecl install apc
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/

# Install PHP extensions
RUN install-php-extensions ldap
RUN docker-php-ext-enable ldap

This is the message I am getting : ldap (ldap) is already loaded!

stevebauman commented 2 years ago

Hi @hekler91,

I’m 100% confident that the error message you’re seeing is due to the extension not being enabled. I would check to make sure that you’re issuing the command on the proper docker container against a PHP version with the LDAP extension enabled.

Try running the below command on your container to make sure it’s enabled:

php -r "print_r(get_loaded_extensions());”
hekler91 commented 2 years ago

I solved it, thank you very much for the support.

stevebauman commented 2 years ago

Excellent, happy to help @hekler91! Im glad you were able to resolve it.