Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

grozavule's avatar

LDAPRecord Laravel Integration

To save my users the trouble of remembering another password, I wanted to authenticate users via Active Directory. I found a package called directorytree/ldaprecord that supposedly can make this work. From my understanding, I need to configure Laravel with the connection parameters for the Active Directory, import all of my AD users to my Laravel database, and authentication should work.

When I run the following command, I get a successful connection to the Active Directory server:

php artisan ldap:test

When I run the following command, it tells me that 0 out of 80 users were imported.

php artisan ldap:import ldap

I've tried the import using both a standard and domain administrator account. Neither allows me to import the users. Has anyone used this package before? Does anyone know of anything else that may work better?

0 likes
4 replies
Sinnbeck's avatar

Yeah I use it daily one two projects.

Did you create a user with elevated rights to do the queries?

grozavule's avatar

I configured the package to use the domain administrator at one point. Are you referring to something else?

grozavule's avatar

Does LDAPRecord authenticate using the username and password in the default Laravel database, or does it query the domain controller?

Sinnbeck's avatar

Well it first of uses the credentials you supplied to do the lookup. If a user is logging in, then that user does not query the AD him/herself. It is always the ldap account that you have added in config, that does the query. The same for import.

This is how I got mine working (the user is a special account made for only this purpose. It is only part of "Domain Users" group)

LDAP_CONNECTION=default
[email protected]
LDAP_PASSWORD=password
LDAP_PORT=389
LDAP_BASE_DN="dc=myactivedirectorydomain,dc=com"

Please or to participate in this conversation.