ldapquery

A custom n8n node for querying and managing LDAP/Active Directory servers with AI-powered natural language query support

Package Information

Released: 13 mo ago
Downloads: 5 weeklyĀ /Ā 19 monthly
Latest Version: 1.1.0
Author: Widji Santoso

Documentation

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-ldapquery

Option 2: Manual Installation

  1. Clone this repository
  2. Build the project:
    npm install
    npm run build
    
  3. Copy the dist folder to your n8n custom nodes directory

Option 3: n8n Community Nodes

  1. Go to Settings > Community Nodes in your n8n instance
  2. Click Install a community node
  3. Enter: n8n-nodes-ldapquery
  4. Click Install

Configuration

LDAP Credentials

Before using this node, you need to configure LDAP credentials:

  1. Go to Credentials in your n8n instance
  2. Click Create New
  3. Select LDAP Credentials
  4. Fill in:
    • LDAP Server URL: ldap://your-server.com:389 or ldaps://your-server.com:636
    • Bind DN: CN=service-account,OU=Users,DC=company,DC=com
    • Bind Password: Your service account password

OpenAI API (Optional)

For natural language query support:

  1. Create OpenAI API credentials
  2. 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 john.doe@company.com

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": "jdoe@company.com",
  "newPassword": "SecurePassword123!",
  "newOu": "OU=Users,DC=company,DC=com",
  "options": {
    "title": "Software Engineer",
    "department": "IT",
    "email": "john.doe@company.com",
    "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

  1. Connection Timeout

    • Check LDAP server URL and port
    • Verify network connectivity
    • Check firewall settings
  2. Authentication Failed

    • Verify Bind DN format
    • Check service account password
    • Ensure account has necessary permissions
  3. SSL/TLS Errors

    • Use ldaps:// for secure connections
    • Enable "Disable Certificate Validation" for testing only
    • Verify certificate chain
  4. 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 start

Development

Building from Source

git clone https://github.com/widjis/LdapQuery.git
cd LdapQuery
npm install
npm run build

Project Structure

src/
ā”œā”€ā”€ LdapQuery.node.ts          # Main node implementation
ā”œā”€ā”€ credentials/
│   └── LdapCredentials.credentials.ts  # Credential definition
└── lib/
    └── ldapService.ts          # LDAP service functions

Dependencies

  • ldapjs: LDAP client library
  • n8n-workflow: n8n workflow types and utilities
  • axios: HTTP client for OpenAI API calls

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. 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

Discussion