Suggest using TLS when connecting to LDAP directly
[mirror/userdir-ldap-cgi.git] / html / doc-direct.wml
1 #use wml::db.d.o title="Direct LDAP Access"
2 #use wml::vbar
3
4 <dsatoc/>
5
6 <p>Since the
7 <a href="https://lists.debian.org/debian-announce/debian-announce-2003/msg00001.html">compromise</a>,
8 the information available to non-developers via the LDAP interface has been
9 limited a great deal. However, as always, the full database is accessible from
10 any .debian.org machine. If you wish relatively unfettered access to the LDAP
11 database, connect to it from a .debian.org machine, such as people.debian.org
12 (which is recommended for general shell usage anyhow).
13 </p>
14
15 <p>
16 The LDAP utilities package (<a href="https://packages.debian.org/ldap-utils">\
17 ldap-utils</a>) provides an utility called ldapsearch that can be used
18 to execute direct queries to the database. This is done by supplying
19 the following arguments to ldapsearch: <strong>-x -H
20 ldaps://db.debian.org -b dc=debian,dc=org</strong>. Alternatively, the
21 <strong>-H</strong> and <strong>-b</strong> options can be put in
22 one's ~/.ldaprc, in the following form:
23 </p><pre>
24 [ dbharris@people: ~/ ]$ cat ~/.ldaprc
25 URI ldaps://db.debian.org
26 BASE dc=debian,dc=org
27 </pre>
28
29 <p>
30 <strong>-x</strong> tells ldapsearch to use "simple" (non-SASL, non-Kerberos)
31 authentication. There appears to be no ~/.ldaprc option which does the same as
32 <strong>-x</strong>. With these parameters specified, we're ready to begin
33 searching. Here's an example:
34 </p><pre>
35 [ dbharris@people: ~/ ]$ ldapsearch -x uid=dbharris keyfingerprint
36 &lt;snip&gt;
37 # dbharris, users, debian, org
38 dn: uid=dbharris,ou=users,dc=debian,dc=org
39 keyFingerPrint: CC53F12435C07BC258FE7A3C157DDFD959DDCB9F
40 &lt;snip&gt;
41 </pre>
42
43 <p>
44 The first non-option argument (<strong>uid=dbharris</strong> in this case) is
45 the query to perform, and the rest of the arguments are the attributes to
46 return. If you only specify the query, but don't provide any attributes to
47 return, all readable attributes are returned. While the example was quite
48 simple, complex queries can be performed as well:
49 </p><pre>
50 [ dbharris@people: ~/ ]$ ldapsearch -x -H ldaps://db.debian.org -b dc=debian,dc=org '(&amp;(!(loginshell=/bin/bash))(uid=*))' loginshell
51 </pre>
52
53 <p>
54 That query shows users that do not use bash as their shell. Some other
55 interesting queries are:</p>
56 <ul>
57 <li>Count the number of developers
58 <tt>(&amp;(keyfingerprint=*)(supplementaryGid=Debian))</tt></li>
59 <li>Show people in a certain group <tt>gidmembership=adm</tt></li>
60 <li>People named james <tt>cn=james</tt></li>
61 <li>Someone whos last name phonetically sounds like 'Ackerma'
62 <tt>sn~=ackerm</tt></li>
63 <li>All the sparcs <tt>host=sparc</tt></li>
64 </ul>
65
66 <p><a href="http://www.faqs.org/rfcs/rfc2254.html">RFC 2254</a>
67 has more information about the filter expressions.</p>
68
69
70 <h1>Other LDAP Browsers</h1>
71 <p>
72 The GQ package has a graphical LDAP browser that can browse the debian.org
73 tree. It is somewhat ungainly with the large number of entries in our
74 directory, but it does work nonetheless. Configuration is similar, use the
75 preferences dialog to add a new host with the information given above.
76 <p>
77 Netscape has a browser for their mailer, but I have never been able to get
78 it to work, please email if you have any luck.
79 <p>
80 To my knowledge there are no interfaces for popular mailers like mutt and
81 gnus. Such an interface would allow using the directory as an enhanced address
82 book.