
ldap-cli
ldap-cli is a cross-platform compatible LDAP-based command-line interface allowing ETL operations on Directory objects using LDAP Data Interchange Format (LDIF).
Developed as Computer Science Project for IU (www.iu-fernstudium.de).
Installation
Download executable binary from the release section, e.g.:
$ latest=$(curl -fsSI https://github.com/sarumaj/ldap-cli/releases/latest | grep -i location | sed 's/\r$//' | awk -F/ '{print $NF}') && \
curl -fsSL "https://github.com/sarumaj/ldap-cli/releases/download/${latest}/ldap-cli_${latest}_linux-amd64" -o /usr/local/bin/ldap-cli
$ chmod +x /usr/local/bin/ldap-cli
Alternatively, build from source code (requires go 1.21.x runtime):
$ git clone https://github.com/sarumaj/ldap-cli
$ cd ldap-cli
$ go build \
-trimpath \
-ldflags="-s -w -X 'main.Version=$(git describe --tags --abbrev=0)' -X 'main.BuildDate=$(date -u "+%Y-%m-%d %H:%M:%S UTC")' -extldflags=-static" \
-tags="osusergo netgo static_build" \
-o /usr/local/bin/ldap-cli \
"cmd/ldap-cli/main.go"
$ chmod +x /usr/local/bin/ldap-cli
Features
- LDAP/LDAPS authentication
- SIMPLE BIND
- NTLM (not tested)
- UNAUTHENTICATED
- MD5 (not tested)
- Search directory objects
- Track progress of search operations
- Search users with options (user-id, enabled, expired, memberOf)
- Search groups with options (group-id)
- Search by providing custom LDAP filter
- Parse and validate filter syntax
- Register lexical aliases
- Edit directory objects
- Edit group members
- Support arbitrary membership attribute
- LDIF edit mode
- Edit user's password
- Support arbitrary password attribute
- Option to pass old password (not available in LDIF mode)
- LDIF edit mode
- Edit custom objects
- Interactive mode operandi
- Ask for inputs
- Utilize ANSI code sequences if available
- Support multiple output format (CSV, LDIF, YAML)
Usage
$ ldap-cli --help
>> ldap-cli is cross-platform compatible client application based on the lightweight directory access control (LDAP)
>>
>> Usage:
>> ldap-cli [flags]
>> ldap-cli [command]
>>
>> Examples:
>> ldap-cli --user "DOMAIN\\user" --password "password" --url "ldaps://example.com:636" <command>
>>
>> Available Commands:
>> completion Generate the autocompletion script for the specified shell
>> edit Edit a directory object
>> get Get a directory object
>> help Help about any command
>> version Display version information
>>
>> Flags:
>> --auth-type string Set authentication schema (supported: ["MD5", "NTLM", "SIMPLE", "UNAUTHENTICATED"]) (default "UNAUTHENTICATED")
>> --debug Set log level to debug
>> --disable-tls Disable TLS (not recommended)
>> --domain string Set domain (required for NTLM authentication schema)
>> -h, --help help for ldap-cli
>> --max-retries uint Specify number of retries (default 3)
>> --password string Set password (will be ignored if authentication schema is set to UNAUTHENTICATED)
>> --size-limit int Specify query size limit (-1: unlimited) (default 2000)
>> --timeout duration Specify query timeout (default 10m0s)
>> --url string Provide address of the directory server (default "ldap://localhost:389")
>> --user string Set username (will be ignored if authentication schema is set to UNAUTHENTICATED)
>>
>> Use "ldap-cli [command] --help" for more information about a command.