259
|
1 ;;; ldap.el --- LDAP support for Emacs
|
|
2
|
|
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
|
|
4
|
|
5 ;; Author: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch>
|
|
6 ;; Maintainer: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch>
|
|
7 ;; Created: Jan 1998
|
261
|
8 ;; Version: $Revision: 1.2 $
|
259
|
9 ;; Keywords: help comm
|
|
10
|
|
11 ;; This file is part of XEmacs
|
|
12
|
|
13 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
14 ;; under the terms of the GNU General Public License as published by
|
|
15 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
16 ;; any later version.
|
|
17
|
|
18 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21 ;; General Public License for more details.
|
|
22
|
|
23 ;; You should have received a copy of the GNU General Public License
|
|
24 ;; along with XEmacs; see the file COPYING. If not, write to
|
|
25 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
26 ;; Boston, MA 02111-1307, USA.
|
|
27
|
|
28 ;;; Commentary:
|
|
29 ;; This file provides mid-level and user-level functions to access directory
|
|
30 ;; servers using the LDAP protocol (RFC 1777).
|
|
31
|
|
32 ;;; Installation:
|
|
33 ;; LDAP support must have been built into XEmacs.
|
|
34
|
|
35
|
|
36 ;;; Code:
|
|
37
|
261
|
38 (eval-when '(load eval)
|
|
39 (require 'ldap-internal))
|
259
|
40
|
|
41 (defvar ldap-host-parameters-alist nil
|
|
42 "An alist describing per host options to use for LDAP transactions
|
|
43 The list has the form ((HOST OPTION OPTION ...) (HOST OPTION OPTION ...))
|
|
44 HOST is the name of an LDAP server. OPTIONs are cons cells describing
|
|
45 parameters for the server. Valid options are:
|
|
46 (binddn . BINDDN)
|
|
47 (passwd . PASSWD)
|
|
48 (auth . AUTH)
|
|
49 (base . BASE)
|
|
50 (scope . SCOPE)
|
|
51 (deref . DEREF)
|
|
52 (timelimit . TL)
|
|
53 (sizelimit . SL))
|
|
54 BINDDN is the distinguished name of the user to bind as (in RFC 1779 syntax).
|
|
55 PASSWD is the password to use for simple authentication.
|
|
56 AUTH is the authentication method to use, possible values are:
|
|
57 `simple', `krbv41' and `krbv42'.
|
|
58 BASE is the base for the search as described in RFC 1779.
|
|
59 SCOPE is one of the three symbols `subtree', `base' or `onelevel'.
|
|
60 DEREF is one of the symbols `never', `always', `search' or `find'.
|
|
61 TL is the timeout limit for the connection in seconds.
|
|
62 SL is the maximum number of matches to return." )
|
|
63
|
|
64
|
|
65 (defun ldap-search (filter &optional host attributes attrsonly)
|
|
66 "Perform an LDAP search.
|
|
67 FILTER is the search filter in RFC1558 syntax
|
|
68 HOST is the LDAP host on which to perform the search
|
|
69 ATTRIBUTES is the specific attributes to retrieve, nil means
|
|
70 retrieve all
|
|
71 ATTRSONLY if non nil retrieves the attributes only without
|
|
72 the associated values.
|
|
73 Additional search parameters can be specified through
|
|
74 `ldap-host-parameters-alist' which see."
|
|
75 (interactive "sFilter:")
|
|
76 (let (host-alist)
|
|
77 (if (null host)
|
|
78 (setq host ldap-default-host))
|
|
79 (if (null host)
|
|
80 (error "No LDAP host specified"))
|
|
81 (setq host-alist
|
|
82 (assoc host ldap-host-parameters-alist))
|
|
83 (ldap-search-internal (append
|
|
84 (list 'host host
|
|
85 'filter filter
|
|
86 'attributes attributes
|
|
87 'attrsonly attrsonly)
|
|
88 (alist-to-plist host-alist)))
|
|
89 ))
|
|
90
|
|
91
|
|
92
|
|
93 (provide 'ldap)
|
|
94
|
|
95 ;;; ldap.el ends here
|