⚠️ DEMO PURPOSES ONLY: This project is a demonstration, not intended for production use. It intentionally omits some security features (like TLS) to simplify local testing and learning.
This project demonstrates the integration between Laravel and OpenLDAP, providing a web interface for managing LDAP users. The application allows you to create, list, and delete users while organizing them into admin and guest groups.
For ease of learning and local testing, this demo intentionally:
- Disables TLS/SSL encryption
- Uses default credentials
- Exposes ports locally
- Lacks user authentication
- Uses basic Docker configurations
These simplifications make it easier to understand the core concepts but would need to be addressed for any production deployment.
php-ldap/
├── open-ldap/ # OpenLDAP Docker setup
│ ├── docker-compose.yaml
│ └── ldap/ # LDAP data directories
│ ├── config/
│ └── data/
└── laravel-ldap/ # Laravel application
├── app/
├── resources/
└── ...
- Docker and Docker Compose (v2.0+)
- PHP 8.2+
- Composer
- Git
- osixia/openldap:1.5.0
- osixia/phpldapadmin:0.9.0
- PHP ^8.2
- Laravel Framework ^11.31
- directorytree/ldaprecord-laravel ^3.3
- Other dependencies as specified in composer.json
- Clone the repository:
git clone <repository-url>
cd php-ldap
- Start the OpenLDAP server:
cd open-ldap
docker-compose up -d
- Set up the Laravel application:
cd ../laravel-ldap
composer install
cp .env.example .env
php artisan key:generate
- Configure Laravel's
.env
file with LDAP settings:
LDAP_HOST=localhost
LDAP_USERNAME="cn=admin,dc=example,dc=org"
LDAP_PASSWORD=admin123
LDAP_PORT=389
LDAP_BASE_DN="dc=example,dc=org"
LDAP_TIMEOUT=5
- Start the Laravel development server:
php artisan serve
-
phpLDAPadmin Interface: http://localhost:8080
- Login DN:
cn=admin,dc=example,dc=org
- Password:
admin123
- Login DN:
-
Laravel Application: http://localhost:8000
-
Creating a User
- Navigate to http://localhost:8000/create-user
- Fill in the required information:
- Username (must be unique)
- First Name
- Last Name
- Password (must meet security requirements)
- UID (unique number between 1000-65534)
- Role (admin or guest)
-
Listing Users
- Navigate to http://localhost:8000/list-users
- View separate sections for Admin and Guest users
- Use the search bar to filter users by name, username, or email
-
Deleting Users
- On the list users page
- Click the "Delete" button next to a user
- Confirm the deletion when prompted
The LDAP server is configured with the following structure:
dc=example,dc=org
└── ou=users
├── cn=admins
└── cn=guests
-
If you can't connect to LDAP:
- Ensure the OpenLDAP container is running:
docker ps
- Check LDAP logs:
docker logs openldap
- Verify Laravel's .env LDAP configuration
- Ensure the OpenLDAP container is running:
-
If user creation fails:
- Ensure unique UID and username
- Check LDAP server logs for detailed error messages
- Verify LDAP connection settings
If you plan to adapt this demo for production use, you would need to:
-
Security Measures:
- Enable and properly configure TLS/SSL
- Change all default passwords
- Implement proper access controls and user authentication
- Use secure LDAP configurations
- Add input validation and sanitization
- Implement proper error handling
-
Infrastructure:
- Use proper Docker configurations with volumes
- Set up proper networking and firewalls
- Implement monitoring and logging
- Configure backups
- Set up high availability if needed
-
Application:
- Add user session management
- Implement proper access control lists
- Add audit logging
- Implement proper error handling
- Add proper validation and security headers
This project is open-sourced software licensed under the MIT license.