This guide helps you migrate from the monolithic LDAP server (v0.x) to the new modular architecture (v1.x).
LDAPServer/
├── src/
│ ├── server.js # Main server
│ ├── auth/providers/ # Auth backends
│ ├── services/ # Database services
│ └── utils/ # Utilities
└── package.json # Single package
LDAPServer/
├── npm/ # @ldap-gateway/core (reusable)
│ ├── src/interfaces/ # Provider interfaces
│ ├── src/utils/ # Core utilities
│ └── src/LdapEngine.js # Main engine
├── server/ # ldap-gateway-server (standalone)
│ ├── src/providers.js # Provider factory
│ └── serverMain.js # Server implementation
└── package.json # Workspace coordinator
git clone repo
cd LDAPServer
npm install
cp src/.env.example src/.env
node src/server.jscurl -LO https://github.com/mieweb/LDAPServer/releases/latest/download/ldap-gateway-linux.tar.gz
tar -xzf ldap-gateway-linux.tar.gz
sudo ./install.sh
systemctl start ldap-gatewaygit clone repo
cd LDAPServer
npm install
cp server/.env.example server/.env
npm run dev| Old Location | New Location | Notes |
|---|---|---|
src/.env |
server/.env |
Development setup |
src/.env |
/etc/ldap-gateway/.env |
Production (binary install) |
Configuration syntax has changed - backend names and SQL configuration updated:
# Backend names changed from 'mysql' to 'sql'
DIRECTORY_BACKEND=sql # Changed from 'mysql'
AUTH_BACKENDS=sql,ldap # Changed from 'mysql,ldap'
# SQL configuration now uses connection URL and custom queries
SQL_URL=mysql://user:password@localhost:3306/database # Replaces MYSQL_HOST, MYSQL_PORT, etc.
SQL_QUERY_ONE_USER='SELECT * FROM users WHERE username = ?'
SQL_QUERY_ALL_USERS='SELECT * FROM users'
SQL_QUERY_GROUPS_BY_MEMBER='SELECT * FROM groups WHERE member = ?'
SQL_QUERY_ALL_GROUPS='SELECT * FROM groups'
# Other settings remain the same
LDAP_BIND_DN=...
# etc.// src/server.js modifications
const ldap = require('ldapjs');
const server = ldap.createServer();
server.bind('...', (req, res, next) => {
// Custom authentication logic
});// Use @ldap-gateway/core for reusable components
const { LdapEngine, AuthProvider } = require('@ldap-gateway/core');
class MyCustomAuthProvider extends AuthProvider {
async authenticate(username, password, req) {
// Your custom logic here
return { success: true, user: {...} };
}
}
const engine = new LdapEngine({
authProvider: new MyCustomAuthProvider(),
// ... other config
});// src/auth/providers/auth/myBackend.js
class MyBackend {
async authenticate(username, password) {
// Custom logic
}
}// npm/src/providers/MyAuthProvider.js
const { AuthProvider } = require('@ldap-gateway/core');
class MyAuthProvider extends AuthProvider {
async authenticate(username, password, req) {
// Same logic, enhanced interface
return { success: true, user: {...} };
}
}
// Register via Provider Factory
// server/src/providers.js
const providers = {
auth: {
// ...existing
my: () => new MyAuthProvider()
}
};FROM node:24
COPY src/ /app/src/
COPY package.json /app/
RUN npm install
CMD ["node", "src/server.js"]FROM node:24
# Option 1: Use binary release
COPY ldap-gateway /usr/local/bin/
CMD ["ldap-gateway"]
# Option 2: Use workspace
COPY package.json /app/
COPY npm/ /app/npm/
COPY server/ /app/server/
RUN npm install
CMD ["npm", "run", "start"][Unit]
Description=LDAP Server
After=network.target
[Service]
Type=simple
User=ldap
WorkingDirectory=/opt/ldapserver
ExecStart=/usr/bin/node src/server.js
Restart=always
[Install]
WantedBy=multi-user.target[Unit]
Description=LDAP Gateway
After=network.target
[Service]
Type=simple
User=ldap-gateway
WorkingDirectory=/opt/ldap-gateway
ExecStart=/usr/local/bin/ldap-gateway
EnvironmentFile=/etc/ldap-gateway/.env
Restart=always
[Install]
WantedBy=multi-user.target-
Configuration Test
# Old: Check manually cat src/.env # New: Built-in validation ldap-gateway --config-test
-
Service Test
# Same LDAP queries work ldapsearch -x -H ldaps://localhost:636 -b "dc=company,dc=com" "(uid=test)"
-
Authentication Test
# Same SSH authentication ssh test@ldap-client-host
Cause: Old import paths Solution: Use new module structure
// Old
const utils = require('./src/utils/ldapUtils');
// New
const { ldapUtils } = require('@ldap-gateway/core');Cause: Binary not executable Solution:
chmod +x /usr/local/bin/ldap-gatewayCause: Config file in old location Solution:
# Copy to new location
sudo cp src/.env /etc/ldap-gateway/.env
# Or set explicit path
ldap-gateway --config=/path/to/.env- Backup existing configuration files
- Install new version (binary/package/source)
- Copy
.envto new location - Test configuration with
ldap-gateway --config-test - Start new service
- Verify LDAP queries work
- Test authentication flows
- Update monitoring/logging paths
- Remove old installation
- Slack: #ldap-gateway
- Issues: GitHub Issues
- Email: support@mieweb.com
- ✅ Modular Architecture - Reusable core package
- ✅ Better Packaging - .deb/.rpm packages with systemd
- ✅ Improved Testing - Automated CI/CD pipeline
- ✅ Documentation - Comprehensive API docs
- ✅ Distribution - Multiple install options
- ✅ Backward Compatibility - Same configuration format