I got tired of typing long ldapsearch commands just to check someone’s AD groups, so I made a small CLI for it
Checking which groups a user is in usually means something like this:
And then you still have to read the group names out of full DNs like CN=VPN-Users,OU=Groups,DC=example,DC=com.
So I wrote cldap, a small Go CLI for LDAP / Active Directory. You set up the connection once, log in once, and then queries are short:
The output is just the group names, one per line, so it’s easy to pipe into grep:
Works with Active Directory (userPrincipalName / sAMAccountName) and OpenLDAP (uid)
Supports LDAPS and StartTLS
Single binary: go install github.com/thedeceptio/cldap@latest
Config and login are saved in ~/.cldap/ with 0600 permissions
Right now it only does group lookups. I’d like to add user lookups and group-member listing next. What would you want from a tool like this?
GitHub: https://github.com/thedeceptio/cldap
ldapsearch -H ldap://dc.example.com -D "user@example.com" -W \ -b "dc=example,dc=com" "(mail=colleague@example.com)" memberOf
cldap configure # host, port, base DN, username attribute, TLS cldap login cldap groups # your own groups cldap groups --email colleague@example.com # someone else's
VPN-Users Engineering Jira-Admins
commit 4424da3