n8n-nodes-ldapquery
v1.1.0
Published
A custom n8n node for querying and managing LDAP/Active Directory servers with AI-powered natural language query support
Maintainers
Readme
n8n-nodes-ldapquery
A custom n8n node for querying and managing LDAP/Active Directory servers with AI-powered natural language query support.
Features
- 🔍 LDAP Query Operations: Search users, groups, and other objects in your LDAP directory
- 🤖 AI-Powered Natural Language Queries: Convert plain English queries to LDAP filters using OpenAI
- 👤 User Creation: Create new Active Directory users with comprehensive attributes
- 🔐 Secure Authentication: Support for bind DN authentication with optional SSL/TLS
- 📊 Pagination Support: Handle large result sets with configurable page sizes
- 🎛️ Flexible Configuration: Extensive options for user creation and query customization
Installation
Option 1: Install from npm (Recommended)
npm install n8n-nodes-ldapqueryOption 2: Manual Installation
- Clone this repository
- Build the project:
npm install npm run build - Copy the
distfolder to your n8n custom nodes directory
Option 3: n8n Community Nodes
- Go to Settings > Community Nodes in your n8n instance
- Click Install a community node
- Enter:
n8n-nodes-ldapquery - Click Install
Configuration
LDAP Credentials
Before using this node, you need to configure LDAP credentials:
- Go to Credentials in your n8n instance
- Click Create New
- Select LDAP Credentials
- Fill in:
- LDAP Server URL:
ldap://your-server.com:389orldaps://your-server.com:636 - Bind DN:
CN=service-account,OU=Users,DC=company,DC=com - Bind Password: Your service account password
- LDAP Server URL:
OpenAI API (Optional)
For natural language query support:
- Create OpenAI API credentials
- Add your OpenAI API key
Usage
Query Operations
Natural Language Queries
Find all users in the Sales department
Show me John Smith's contact information
List all disabled accounts
Find users with manager email [email protected]Manual LDAP Filters
(objectClass=person)
(&(objectClass=user)(department=Sales))
(&(cn=John*)(mail=*))
(userAccountControl:1.2.840.113556.1.4.803:=2)User Creation
Create new Active Directory users with:
- Required Fields: Full Name, Last Name, First Name, Username, UPN, Password, Target OU
- Optional Fields: Title, Department, Email, Phone, Manager, Company, Office
Examples
Basic User Query
{
"operation": "query",
"searchBase": "DC=company,DC=com",
"searchFilter": "(objectClass=person)",
"attributes": "cn,mail,department",
"pageSize": 100
}AI-Powered Query
{
"operation": "query",
"nlQuery": "Find all users in IT department",
"searchBase": "DC=company,DC=com",
"attributes": "cn,mail,title,department"
}Create New User
{
"operation": "create",
"newCn": "John Doe",
"newSn": "Doe",
"newGivenName": "John",
"newUsername": "jdoe",
"newUpn": "[email protected]",
"newPassword": "SecurePassword123!",
"newOu": "OU=Users,DC=company,DC=com",
"options": {
"title": "Software Engineer",
"department": "IT",
"email": "[email protected]",
"phoneNumber": "+1-555-0123"
}
}Node Properties
Query Operation
| Property | Type | Description | |----------|------|-------------| | Natural Language Query | string | Plain English query (requires OpenAI API) | | Manual Search Filter | string | LDAP filter syntax | | Search Base | string | Base DN for search | | Attributes | string | Comma-separated list of attributes | | Page Size | number | Maximum results per page | | AI System Prompt | string | Custom prompt for AI query conversion |
Create User Operation
| Property | Type | Description | |----------|------|-------------| | Full Name | string | Complete name (CN) | | Last Name | string | Surname (sn) | | First Name | string | Given name | | Username | string | sAMAccountName | | UPN | string | User Principal Name | | Password | string | User password | | Target OU | string | Organizational Unit DN | | Options | collection | Additional user attributes |
Security Considerations
- Use service accounts with minimal required permissions
- Enable SSL/TLS for production environments
- Store credentials securely in n8n's credential system
- Regularly rotate service account passwords
- Monitor LDAP access logs
Troubleshooting
Common Issues
Connection Timeout
- Check LDAP server URL and port
- Verify network connectivity
- Check firewall settings
Authentication Failed
- Verify Bind DN format
- Check service account password
- Ensure account has necessary permissions
SSL/TLS Errors
- Use
ldaps://for secure connections - Enable "Disable Certificate Validation" for testing only
- Verify certificate chain
- Use
Search Returns No Results
- Check search base DN
- Verify LDAP filter syntax
- Ensure attributes exist in schema
Debug Mode
Enable debug logging in n8n to see detailed LDAP operations:
N8N_LOG_LEVEL=debug npm startDevelopment
Building from Source
git clone https://github.com/widjis/LdapQuery.git
cd LdapQuery
npm install
npm run buildProject Structure
src/
├── LdapQuery.node.ts # Main node implementation
├── credentials/
│ └── LdapCredentials.credentials.ts # Credential definition
└── lib/
└── ldapService.ts # LDAP service functionsDependencies
ldapjs: LDAP client libraryn8n-workflow: n8n workflow types and utilitiesaxios: HTTP client for OpenAI API calls
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details
Support
For issues and questions:
- Create an issue on GitHub
- Check the n8n community forum
- Review the troubleshooting section above
Changelog
v1.0.0
- Initial release
- LDAP query and user creation operations
- AI-powered natural language queries
- Comprehensive user attribute support
- SSL/TLS support with certificate validation options
