A comprehensive Flask-based web application for LDAP administration and user self-service portal built with Bootstrap 5.
- User Login: Normal users can login with their LDAP credentials
- Profile Management: Users can update their personal information (email, phone, description, etc.)
- Profile Photos: Upload and manage profile photos using jpegPhoto attribute with automatic resizing
- Password Change: Secure password change functionality with SSHA encryption
- Password Expiry Information: View password expiry status and remaining days (POSIX users)
- User Directory: Browse and search other users in the organization
- Clean Dashboard: Intuitive interface showing account status and quick actions
- Full system access with all administrative privileges
- System account protection (cannot modify own profile)
- Login: Use username
admin
with admin DN credentials
- User management capabilities
- Group management access
- Limited administrative privileges
- Self-profile modification allowed
- β Complete User Management: Create, read, update, delete user accounts
- β POSIX User Support: Create users with POSIX attributes (UID, GID, home directory, shell)
- β
Complete Group Management:
- Create both standard and POSIX groups
- Delete existing groups
- Add/remove members from groups
- View group membership details
- β Bulk User Creation: Upload CSV files to create multiple users at once
- β Profile Photo Management: Upload, preview, and manage user photos (jpegPhoto attribute)
- β Password Expiry Management: View and manage password expiration for POSIX users
- β User Search & Filtering: Search users by name, email, or other attributes
- β Comprehensive Statistics: LDAP server statistics dashboard with user/group counts
- β Generic Entry Editor: Edit any LDAP entry with all attributes
- β Lock/Unlock Users: Temporarily disable user accounts
- β Admin Dashboard: Comprehensive administrative interface with real-time statistics
- β Security Features: Environment-based configuration, secure password handling
- Backend: Python 3.12+ with Flask
- Frontend: Bootstrap 5 with Font Awesome icons
- LDAP Client: ldap3 library for robust LDAP operations
- Authentication: Session-based authentication with LDAP bind
- Security: Environment variable configuration, no hardcoded passwords
-
Set up environment variables:
export LDAP_ADMIN_PASSWORD="your_admin_password"
Or use the interactive setup script:
./setup_env.sh
-
Install dependencies:
python -m venv .venv source .venv/bin/activate pip install -r requirements.txt
-
Run the application:
python app.py
-
Access the portal:
- URL: http://localhost:5000
- Admin Login: Username
admin
+ your LDAP admin password - User Login: Any valid LDAP user credentials
For production deployment with systemd service, Nginx proxy, and complete LDAP server setup, see the comprehensive SETUP.md guide.
The application supports environment-based configuration:
Environment Variable | Default Value | Description |
---|---|---|
LDAP_SERVER |
192.168.1.1 |
LDAP server hostname/IP |
LDAP_PORT |
389 |
LDAP server port |
LDAP_BASE_DN |
dc=mylab,dc=lan |
LDAP base DN |
LDAP_ADMIN_DN |
cn=admin,dc=mylab,dc=lan |
LDAP admin DN |
LDAP_ADMIN_PASSWORD |
(Required) | LDAP admin password |
DEBUG_MODE |
False |
Enable debug logging (set to true only for development) |
- β No hardcoded passwords - All credentials via environment variables
- β Secure session management - Flask-Session with filesystem storage
- β LDAP authentication - Direct LDAP bind for user verification
- β Multi-tier access control - Super admin vs Group admin privileges
- β Input validation - Form validation and LDAP injection prevention
- β Secure configuration - Environment-based sensitive data handling
pythonldapman/
βββ app.py # Main Flask application
βββ requirements.txt # Python dependencies
βββ setup_env.sh # Environment setup script
βββ INSTALLATION.md # Complete installation guide
βββ static/ # Frontend assets (CSS, JS, images)
βββ templates/ # Jinja2 HTML templates
βββ config/ # Configuration files (created during setup)
This project is developed for LDAP administration and user self-service purposes.
For installation and configuration issues, refer to SETUP.md or check the application logs.
python app.py
-
Open your web browser and go to:
http://localhost:5000
-
Login credentials:
- Admin: Username
admin
with your admin password - Users: Use their LDAP username and password
- Admin: Username
- Login with your LDAP username and password
- Navigate to "My Profile" to update your information
- Use "Change Password" to update your password
- All changes are saved directly to the LDAP directory
- Login with username
admin
and your admin password - Access the "Admin Panel" from the navigation menu
- Manage users through "Manage Users"
- Create new users with "Add New User"
- Edit any LDAP entry with the generic entry editor
- Delete entries with confirmation dialogs
- LDAP Authentication: All logins verified against LDAP server
- Session Management: Secure session handling with Flask-Session
- Password Hashing: SSHA password hashing for new passwords
- Access Control: Role-based access with user/admin separation
- Input Validation: Form validation and sanitization
The application supports standard LDAP object classes:
- uid (username)
- cn (common name)
- sn (surname)
- givenName (first name)
- mail (email)
- telephoneNumber (phone)
- userPassword (password)
- description
- cn (group name)
- description
- member (group members)
pythonldapman/
βββ app.py # Main Flask application
βββ requirements.txt # Python dependencies
βββ templates/ # Jinja2 templates
β βββ base.html # Base template with Bootstrap
β βββ login.html # Login page
β βββ dashboard.html # User dashboard
β βββ profile.html # User profile editor
β βββ change_password.html # Password change form
β βββ admin/ # Admin templates
β βββ panel.html # Admin dashboard
β βββ users.html # User management
β βββ groups.html # Group management
β βββ add_user.html # Add user form
β βββ edit_entry.html # Generic entry editor
βββ static/ # Static files (if needed)
Edit the configuration variables in app.py
:
LDAP_SERVER = '192.168.1.1'
LDAP_PORT = 389
LDAP_BASE_DN = 'dc=mylab,dc=lan'
LDAP_ADMIN_DN = 'cn=admin,dc=mylab,dc=com'
- Templates use Bootstrap 5 classes for easy customization
- Modify
templates/base.html
for global layout changes - Add custom CSS in the
static/
directory
The application includes comprehensive error handling:
- LDAP connection errors
- Authentication failures
- Invalid form data
- Missing entries
- Permission denied scenarios
To contribute or modify the application:
- The main application logic is in
app.py
- Templates are in the
templates/
directory - Use the Flask development server for testing
- All LDAP operations go through the
LDAPManager
class
This project is open-source and available for modification and distribution.
For issues or questions:
- Check the LDAP server connectivity
- Verify credentials and DN configuration
- Review Flask application logs
- Test LDAP operations manually with ldapsearch