SHELLDAP(1p) | User Contributed Perl Documentation | SHELLDAP(1p) |
Shelldap - A program for interacting with an LDAP server via a shell-like interface
Shelldap /LDAP::Shell is a program for interacting with an LDAP server via a shell-like interface.
This is not meant to be an exhaustive LDAP editing and browsing interface, but rather an intuitive shell for performing basic LDAP tasks quickly and with minimal effort.
shelldap --server example.net [--help]
- Upon successful authenticated binding, credential information is auto-cached to ~/.shelldap.rc -- future loads require no command line flags. - Custom 'description maps' for entry listings. (See the 'list' command.) - History and autocomplete via readline, if installed. - Automatic reconnection attempts if the connection is lost with the LDAP server. - Basic schema introspection for quick reference. - It feels like a semi-crippled shell, making LDAP browsing and editing at least halfway pleasurable.
All command line options follow getopts long conventions.
shelldap --server example.net --basedn dc=your,o=company
You may also optionally create a ~/.shelldap.rc file with command line defaults. This file should be valid YAML. (This file is generated automatically on a successful bind auth.)
Example:
server: ldap.example.net binddn: cn=Manager,dc=your,o=company bindpass: xxxxxxxxx basedn: dc=your,o=company tls: yes tls_cacert: /etc/ssl/certs/cacert.pem tls_cert: ~/.ssl/client.cert.pem tls_key: ~/.ssl/private/client.key.pem
--configfile /tmp/alternate-config.yml -f /tmp/alternate-config.yml
This config file overrides values found in the default config, so you can easily have separate config files for connecting to your cn=monitor or cn=log overlays (for example.)
--server ldaps://ldap.example.net -H ldaps://ldap.example.net
--binddn cn=Manager,dc=your,o=company -D cn=Manager,dc=your,o=company
--basedn dc=your,o=company -b dc=your,o=company
--paginate 100
--sasl 'PLAIN DIGEST-MD5 EXTERNAL GSSAPI' -Y 'PLAIN DIGEST-MD5 EXTERNAL GSSAPI'
--sasluser mahlon -X mahlon
--tls_cacert /etc/ssl/certs/cacert.pem
--tls_cert ~/.ssl/client.cert.pem
--tls_key ~/.ssl/private/client.key.pem
By default, directory lookups are cached for 300 seconds, to speed autocomplete up when changing between different basedns.
Modifications to the directory automatically reset the cache. Directory listings are not cached. (This is just used for autocomplete.) Set it to 0 to disable caching completely.
cat uid=mahlon cat ou=* cat uid=mahlon,ou=People,dc=example,o=company cat uid=mahlon + userPassword
cd change to 'home' basedn cd ~ change to the binddn, or basedn if anonymously bound cd - change to previous node cd ou=People change to explicit path below current node cd .. change to parent node cd ../../ou=Groups change to node ou=Groups, which is a sibling to the current node's grandparent
Since LDAP doesn't actually limit what can be a container object, you can actually cd into any entry. Many commands then work on '.', meaning "wherever I currently am."
cd uid=mahlon cat .
copy uid=mahlon uid=bob copy uid=mahlon ou=Others,dc=example,o=company copy uid=mahlon,ou=People,dc=example,o=company uid=mahlon,ou=Others,dc=example,o=company
aliased to: cp
After the classes are specified, an editor will launch. Required attributes are listed first, then optional attributes. Optionals are commented out. After the editor exits, the resulting LDIF is validated and added to the LDAP directory.
create top person organizationalPerson inetOrgPerson posixAccount
aliased to: touch
delete uid=mahlon delete uid=ma* rm -v uid=mahlon,ou=People,dc=example,o=company l=office
aliased to: rm
edit uid=mahlon
aliased to: vi
Show values for various runtime variables.
grep uid=mahlon grep uid=mahlon ou=People grep -r (&(uid=mahlon)(objectClass=*)) aliased to: search
inspect uid=mahlon inspect posixAccount organizationalUnit inspect _schema
The output is a list of found objectClasses, their schema hierarchy (up to 'top'), whether or not they are a structural class, and then a merged list of all valid attributes for the given objectClasses. Attributes are marked as either required or optional, and whether they allow multiple values or not.
If you ask for the special "_schema" object, the raw server schema is dumped to screen.
aliased to: ls
ls -l ls -lR uid=mahlon list uid=m*
In 'long' mode, descriptions are listed as well, if they exist. There are some default 'long listing' mappings for common objectClass types. You can additionally specify your own mappings in your .shelldap.rc, like so:
... descmaps: objectClass: attributename posixAccount: gecos posixGroup: gidNumber ipHost: ipHostNumber
mkdir containername mkdir ou=whatever
aliased to: mv
passwd uid=mahlon
setenv debug 1 export debug=1
aliased to: id
Referral support. Currently, if you try to write to a replicant slave, you'll just get a referral. It would be nice if shelldap automatically tried to follow it.
For now, it only makes sense to connect to a master if you plan on doing any writes.
There is no support for editing binary data. If you need to edit base64 stuff, just feed it to the regular ldapmodify/ldapadd/etc tools.
Mahlon E. Smith <mahlon@martini.nu>
2019-10-17 | perl v5.28.1 |