DirectoryTree / LdapRecord

A fully-featured LDAP framework.
https://ldaprecord.com
MIT License
500 stars 44 forks source link

[Bug] Call to undefined function LdapRecord\Models\Attributes\ldap_escape() #721

Closed rangganovsky closed 3 months ago

rangganovsky commented 3 months ago

Hi,

I've just stumble upon the LdapRecord-Laravel and just try the package and to be honest i am not quite sure it is a bug or it is just a mere misconfiguration on my end, I've tried my best to read the documentation but couldn't find any info related to the error. hope you can help guide me on this. I was thinking to put the issue report on the https://github.com/DirectoryTree/LdapRecord-Laravel but then since the error pointed to this package so i decided to post an issue here

Environment:

Describe the bug: I was trying to use as Database Authentication, since i want to sync the LDAP users into our DB for further use in the app, for testing purposes, i was using public LDAP server from ldap.forumsys.com, and was able to connect using php artisan ldap:test command. Myconfig/ldap.php are basically using the default config, just change the .env files to match the creds from ldap.forumsys.com

Here is my config/auth.php

'users' => [
          'driver' => 'ldap',
          'model' => LdapRecord\Models\OpenLDAP\User::class,
          'rules' => [],
          'scopes' => [],
          'database' => [
              'model' => App\Models\User::class,
              'password_column' => 'password',
              'sync_passwords' => true,
              'sync_attributes' => [
                  'name' => 'cn',
                  'email' => 'mail',
              ],
          ],
      ],

Here is my App/users.php

.. other imports
use LdapRecord\Laravel\Auth\LdapAuthenticatable;
use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;

class User extends Authenticatable implements LdapAuthenticatable
{
    use HasApiTokens, HasFactory, Notifiable, HasRoles, UsesUUID, SoftDeletes, AuthenticatesWithLdap;

   .. other codes
}

i was following the docs by adding the Traits to my users model, also run the migration to add guid and domain field to my users table.

When i tried to login to using the mail and password from example public ldap server i've got this error Call to undefined function LdapRecord\Models\Attributes\ldap_escape() at vendor/ directorytree/ ldaprecord / src / Models / Attributes/ EscapedValue.php: 59

Screenshot 2024-05-28 at 00 16 25

here is my full stacktrace for references : https://flareapp.io/share/95JB2RM5

am i missing something here?

Many Thanks, Rangga

stevebauman commented 3 months ago

Hi @rangganovsky,

This is due to your PHP installation not having the LDAP extension enabled. You likely have two different PHP installs on your machine (the one you've ran in the CLI and the one your web server is using).

Dump a phpinfo() on your application and ensure it is installed and enabled.