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
|
282
|
8 ;; Version: $Revision: 1.5 $
|
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)
|
276
|
39 (require 'ldap))
|
|
40
|
|
41 (defvar ldap-default-host nil
|
|
42 "*Default LDAP server.")
|
259
|
43
|
282
|
44 (defvar ldap-host-parameters-plist nil
|
|
45 "*A property list of per host options for LDAP transactions
|
|
46 The list elements look like (HOST PROP1 VAL1 PROP2 VAL2 ...)
|
|
47 HOST is the name of an LDAP server. PROPn and VALn are property/value pairs
|
|
48 describing parameters for the server. Valid properties:
|
|
49 `binddn' is the distinguished name of the user to bind as
|
|
50 (in RFC 1779 syntax).
|
|
51 `passwd' is the password to use for simple authentication.
|
|
52 `auth' is the authentication method to use.
|
|
53 Possible values are: `simple', `krbv41' and `krbv42'.
|
|
54 `base' is the base for the search as described in RFC 1779.
|
|
55 `scope' is one of the three symbols `subtree', `base' or `onelevel'.
|
|
56 `deref' is one of the symbols `never', `always', `search' or `find'.
|
|
57 `timelimit' is the timeout limit for the connection in seconds.
|
|
58 `sizelimit' is the maximum number of matches to return." )
|
259
|
59
|
|
60
|
|
61 (defun ldap-search (filter &optional host attributes attrsonly)
|
|
62 "Perform an LDAP search.
|
|
63 FILTER is the search filter in RFC1558 syntax
|
|
64 HOST is the LDAP host on which to perform the search
|
|
65 ATTRIBUTES is the specific attributes to retrieve, nil means
|
|
66 retrieve all
|
|
67 ATTRSONLY if non nil retrieves the attributes only without
|
|
68 the associated values.
|
|
69 Additional search parameters can be specified through
|
282
|
70 `ldap-host-parameters-plist' which see."
|
259
|
71 (interactive "sFilter:")
|
282
|
72 (let (host-plist res ldap)
|
259
|
73 (if (null host)
|
|
74 (setq host ldap-default-host))
|
|
75 (if (null host)
|
|
76 (error "No LDAP host specified"))
|
282
|
77 (setq host-plist
|
|
78 (cdr (assoc host ldap-host-parameters-plist)))
|
276
|
79 (message "Opening LDAP connection to %s..." host)
|
282
|
80 (setq ldap (ldap-open host host-plist))
|
276
|
81 (message "Searching with LDAP on %s..." host)
|
|
82 (setq res (ldap-search-internal ldap filter
|
282
|
83 (plist-get host-plist 'base)
|
|
84 (plist-get host-plist 'scope)
|
276
|
85 attributes attrsonly))
|
|
86 (ldap-close ldap)
|
|
87 res))
|
259
|
88
|
|
89
|
|
90
|
|
91 (provide 'ldap)
|
|
92
|
|
93 ;;; ldap.el ends here
|