Boring Dragon

Emulating Ldap in Laravel

May 20, 2024 · 3min

Here is a code snippet that I wrote to emulate the ldap in laravel.

AuthServiceProvider.php boot method

 if (app()->isLocal()) {

            $fake = DirectoryEmulator::setup('default');

            $fake->getLdapConnection()->tls(true);

            $user = User::create([
                'cn' => fake()->name,
                'givenName' => fake()->firstName,
                'sn' =>  fake()->lastName,
                'mail' => fake()->email,
                'objectguid' => fake()->uuid,
                'samaccountname' => fake()->username,
            ]);

            Auth::login($user);
        }
>
2025 © Boring Labs