1MUTT_LDAP_QUERY(1)    User Contributed Perl Documentation   MUTT_LDAP_QUERY(1)
2
3
4

NAME

6       mutt_ldap_query - Query LDAP server for Mutt mail-reader
7

SYNOPSIS

9       mutt_ldap_query.pl [options] <name_to_query> [[<other_name_to_query>]
10       ...]
11

OPTIONS

13       --config=config_file or -c config_file
14               specify an alternate resource file other than the system ones
15               (/etc/lbdb_ldap.rc or /etc/mutt_ldap_query.rc) or default
16               personal ones ($HOME/.lbdb/ldap.rc or
17               $HOME/.mutt_ldap_query.rc).
18
19       --server=ldap_server or -ls ldap_server
20               hostname of your ldap server.  You can also use an
21               ldap://foo[:port] or ldaps://foo[:port] URL here to talk to
22               different ports or SSL encrypted servers.  Or use
23               ldapi://%2fvar%2flib%2fldap_sock to access an ldap server via a
24               socket (use %2f as as replacement for a slash in the file
25               name).
26
27       --search_base=ldap_search_base or -sb ldap_search_base
28               use <search_base> as the starting point for the search instead
29               of the default.
30
31       --search_fields=ldap_search_fields or -sf ldap_search_fields
32               list of the fields on which the query will be performed.
33
34       --expected_answers=ldap_expected_answers or -ea ldap_expected_answers
35               list of the fields expected as the answer of the ldap server
36               that will be used for composing the output of the script.
37
38       --format_email=result_format_email or -fe result_format_email
39               format to be used for composing the email output result. It has
40               to be based on the expected ldap server answers and can use
41               variable containers of the form ${variable} where variable
42               belongs to the <ldap_expected_answers> set.
43
44       --format_realname=result_format_realname or -fr result_format_realname
45               format to be used for composing the realname output result. It
46               has to be based on the expected ldap server answers and can use
47               variable containers of the form ${variable} where variable
48               belongs to the <ldap_expected_answers> set.
49
50       --format_comment=result_format_comment or -fc result_format_comment
51               format to be used for composing the comment output result. It
52               has to be based on the expected ldap server answers and can use
53               variable containers of the form ${variable} where variable
54               belongs to the <ldap_expected_answers> set.
55
56       --bind_dn=bind_distinguished_name or -bd bind_distinguished_name
57               the destinguished name of the user who binds to the LDAP
58               server.  Leave it empty for an anonmyous bind.
59
60       --bind_password=secret or -bp secret
61               the bind password for binding to the LDAP server.  Leave it
62               empty for an anonmyous bind.
63
64       --tls=1 or --tls=0
65               enable or disable transport layer security (TLS).
66
67       --sasl_mech=mechanism or -sm mechanism
68               the SASL mechanism, for example GSSAPI (empty string to turn
69               off).
70
71       --nickname=ldap_server_nickname or -n ldap_server_nickname
72               shortcut for avoiding to use all the previous options by using
73               the script builtin or alternate config file table of common
74               servers and associated options.  All the required parameters
75               are then derived by performing a <lbdb_server_nickname> lookup.
76
77       --debug or -d
78               turn on debugging messages.
79
80       --help or -? or -h or --man or -m
81               generates this help message.
82
83       --ignorant or -i
84               ignorant mode: search using wildcard for *name_to_query*
85               (requires a longer processing from LDAP server but is quite
86               convenient :).
87
88       --lbdb_output or -l
89               suppress number of matches output (suited for interfacing with
90               little brother database http://www.spinnaker.de/lbdb/).
91
92       --version or -v
93               show the version.
94

DESCRIPTION

96       mutt_ldap_query performs ldap queries using either ldapsearch command
97       or the perl-ldap module and it outputs the required formatted data for
98       feeding mutt when using its "External Address Query" feature.
99
100       The output of the script consists in 3 fields separated with tabs: the
101       email address, the name of the person and a comment.
102

INTERFACING WITH MUTT

104       This perl script can be interfaced with mutt by defining in your
105       .muttrc:
106
107           set query_command = "mutt_ldap_query.pl %s"
108
109       Multiple requests are supported: the "Q" command of mutt accepts as
110       argument a list of queries (e.g. "Gosse de\ Courville").
111
112       Alternatively mutt_ldap_query can be interfaced with the more generic
113       little brother database query program (http://www.spinnaker.de/lbdb/)
114       using:
115
116           set query_command = "lbdbq %s"
117
118       and by specifying in your ~/.lbdb/lbdbrc file another method of query
119       just adding to the METHODS variable the m_ldap module e.g.:
120
121           METHODS='m_inmail m_passwd m_ldap m_muttalias m_finger'
122
123       and the right path to access m_ldap in MODULES_PATH, e.g. if you moved
124       m_ldap in ~/.lbdb/modules:
125
126           MODULES_PATH="/usr/local/lib $HOME/.lbdb/modules"
127
128       Just make sure to use the correct path for calling mutt_ldap_query in
129       the m_ldap script.
130

RESOURCE FILE FORMAT

132       mutt_ldap_query is now fully customizable using an external resource
133       file. By default mutt_ldap_query parses the system definition file
134       located generally at /etc/mutt_ldap_query.rc or
135       /usr/local/etc/mutt_ldap_query.rc and also the user one:
136       $HOME/.mutt_ldap_query.rc.
137
138       Instead of using command line options, the user can redefine all the
139       variables using the resource file by two manners in order to match his
140       site configuration.  A file example is provided below:
141
142           # The format of each entry of the ldap server database is the following:
143           # LDAP_NICKNAME => ['LDAP_SERVER',
144           #                   'LDAP_SEARCH_BASE',
145           #                   'LDAP_SEARCH_FIELDS',
146           #                   'LDAP_EXPECTED_ANSWERS',
147           #                   'LDAP_RESULT_EMAIL',
148           #                   'LDAP_RESULT_REALNAME',
149           #                   'LDAP_RESULT_COMMENT'],
150
151           # a practical illustrating example being:
152           #  debian   => ['db.debian.org',
153           #               'ou=users,dc=debian,dc=org',
154           #               'uid cn sn ircnick',
155           #               'uid cn sn ircnick',
156           #               '${uid}@debian.org',
157           #               '${cn} ${sn}',
158           #               '${ircnick}'],
159           # the output of the query will be then:
160           # ${uid}@debian.org\t${cn} ${sn}\t${ircnick} (i.e.: email name comment)
161
162           # warning this database will erase default script builtin
163           %ldap_server_db = (
164             'four11'          => ['ldap.four11.com',
165                                   'c=US',
166                                   'givenname sn cn mail',
167                                   'givenname cn sn mail o',
168                                   '${mail}',
169                                   '${givenname} ${sn}',
170                                   '${o}' ],
171             'infospace'       => ['ldap.infospace.com',
172                                   'c=US',
173                                   'givenname sn cn mail',
174                                   'givenname cn sn mail o',
175                                   '${mail}',
176                                   '${givenname} ${sn}',
177                                   '${o}' ],
178             'whowhere'        => ['ldap.whowhere.com',
179                                   'c=US',
180                                   'givenname sn cn mail',
181                                   'givenname cn sn mail o',
182                                   '${mail}',
183                                   '${givenname} ${sn}',
184                                   '${o}' ],
185             'bigfoot'         => ['ldap.bigfoot.com',
186                                   'c=US',
187                                   'givenname sn cn mail'
188                                  , 'givenname cn sn mail o'
189                                  , '${mail}'
190                                  , '${givenname} ${sn}',
191                                   '${o}' ],
192             'switchboard'     => ['ldap.switchboard.com',
193                                   'c=US',
194                                   'givenname sn cn mail'
195                                  , 'givenname cn sn mail o',
196                                   '${mail}',
197                                   '${givenname} ${sn}',
198                                   '${o}' ],
199             'infospacebiz'    => ['ldapbiz.infospace.com',
200                                   'c=US',
201                                   'givenname sn cn mail',
202                                   'givenname cn sn mail o',
203                                   '${mail}',
204                                   '${givenname} ${sn}',
205                                   '${o}' ],
206           );
207
208           # hostname of your ldap server
209           $ldap_server = 'ldap.four11.com';
210           # ldap base search
211           $search_base = 'c=US';
212           # list of the fields that will be used for the query
213           $ldap_search_fields = 'givenname sn cn mail';
214           # list of the fields that will be used for composing the answer
215           $ldap_expected_answers = 'givenname sn cn mail o';
216           # format of the email result based on the expected answers of the ldap query
217           $ldap_result_email = '${mail}';
218           # format of the realname result based on the expected answers of the ldap query
219           $ldap_result_realname = '${givenname} ${sn}';
220           # format of the comment result based on the expected answers of the ldap query
221           $ldap_result_comment = '(${o})';
222

EXAMPLES OF QUERIES

224           mutt_ldap_query.pl --ldap_server='ldap.mot.com' \
225              --search_base='ou=employees, o=Motorola,c=US' \
226              --ldap_search_fields='commonName gn sn cn uid' \
227              --ldap_expected_answers='gn sn preferredRfc822Recipient ou c telephonenumber' \
228              --ldap_result_email='${preferredRfc822Recipient}' \
229              --ldap_result_realname='${gn} ${sn}' \
230              --ldap_result_comment='(${telephonenumber}) ${ou} ${c}' \
231              Gosse de\ Courville
232
233       performs a query using the ldap server ldap.mot.com using the following
234       searching base 'ou=employees, o=Motorola,c=US' and performing a search
235       on the fields 'commonName gn sn cn uid' for 'Gosse' and then "de
236       Courville" looking for the following answers 'gn sn
237       preferredRfc822Recipient ou c telephonenumber'. Based on this answers,
238       mutt_ldap_query will return a list of entries identified of the form:
239
240         <${preferredRfc822Recipient}>\t${gn} ${sn}\t(${telephonenumber}) ${ou} ${c}
241
242       where ${} variables should be considered as containers that are
243       replaced by the results of the query. The previous query can be greatly
244       simplified by using the ldap server mini database feature of the
245       resource file introducing for example a nickname.
246
247           mutt_ldap_query.pl --ldap_server_nickname='motorola' Gosse de\ Courville
248
249       When not sure of the full name (i.e. it should contain Courville) the
250       ignorant mode is useful since the query will be performed using
251       wildcards, i.e. *Courville* in the following case:
252
253           mutt_ldap_query.pl --ignorant Courville
254

WHERE TO GET IT

256       The latest version can be retrieved at
257         ftp://ftp.mutt.org/pub/mutt/contrib or
258         http://www.courville.org/
259
260       Note that now the script is integrated in the latest version of the
261       little brother database available at http://www.spinnaker.de/lbdb/.  It
262       is thus easier to use through this standard package than to hand
263       customize it to fit your system/distribution needs.
264

REFERENCES

266       - perl-ldap module
267          http://perl-ldap.sourceforge.net/
268
269       - mutt is the ultimate email client
270          http://www.mutt.org/
271
272       - historical Brandon Blong's "External Address Query" feature patch for
273         mutt
274          http://www.fiction.net/blong/programs/mutt/#query
275
276       - little brother database is an interface query program for mutt that
277         allow multiple searches for email addresses based on external query
278         scripts just like this one 8-)
279          http://www.spinnaker.de/lbdb/
280

AUTHORS

282       Marc de Courville <marc@courville.org> and the various other
283       contributors... that kindly sent their patches.
284
285       Please report any bugs, or post any suggestions, to
286       <marc@courville.org>.
287
289       Copyright (c) 1998-2003 Marc de Courville <marc@courville.org>. All
290       rights reserved. This program is free software; you can redistribute it
291       and/or modify it under the GNU General Public License (GPL). See
292       http://www.opensource.org/gpl-license.html and
293       http://www.opensource.org/.
294
295
296
297perl v5.30.0                      2019-07-25                MUTT_LDAP_QUERY(1)
Impressum