Mercurial > hg > xemacs-beta
diff lisp/ldap.el @ 371:cc15677e0335 r21-2b1
Import from CVS: tag r21-2b1
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:03:08 +0200 |
parents | 7347b34c275b |
children | bbff43aa5eb7 |
line wrap: on
line diff
--- a/lisp/ldap.el Mon Aug 13 11:01:58 2007 +0200 +++ b/lisp/ldap.el Mon Aug 13 11:03:08 2007 +0200 @@ -5,7 +5,7 @@ ;; Author: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch> ;; Maintainer: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch> ;; Created: Jan 1998 -;; Version: $Revision: 1.9 $ +;; Version: $Revision: 1.7.2.1 $ ;; Keywords: help comm ;; This file is part of XEmacs @@ -35,47 +35,17 @@ ;;; Code: -(eval-when '(load) - (if (not (fboundp 'ldap-open)) - (error "No LDAP support compiled in this XEmacs"))) - -(defgroup ldap nil - "Lightweight Directory Access Protocol" - :group 'comm) +(eval-when '(load eval) + (require 'ldap)) -(defcustom ldap-default-host nil - "*Default LDAP server hostname. -A TCP port number can be appended to that name using a colon as -a separator." - :type '(choice (string :tag "Host name") - (const :tag "Use library default" nil)) - :group 'ldap) +(defvar ldap-default-host nil + "*Default LDAP server.") -(defcustom ldap-default-port nil - "*Default TCP port for LDAP connections. -Initialized from the LDAP library at build time. Default value is 389." - :type '(choice (const :tag "Use library default" nil) - (integer :tag "Port number")) - :group 'ldap) - -(defcustom ldap-default-base nil - "*Default base for LDAP searches. -This is a string using the syntax of RFC 1779. -For instance, \"o=ACME, c=US\" limits the search to the -Acme organization in the United States." - :type '(choice (const :tag "Use library default" nil) - (string :tag "Search base")) - :group 'ldap) - - -(defcustom ldap-host-parameters-alist nil - "*Alist of host-specific options for LDAP transactions. -The format of each list element is: -\(HOST PROP1 VAL1 PROP2 VAL2 ...) -HOST is the hostname of an LDAP server (with an optional TCP port number -appended to it using a colon as a separator). -PROPn and VALn are property/value pairs describing parameters for the server. -Valid properties include: +(defvar ldap-host-parameters-alist nil + "*An alist of per host options for LDAP transactions +The list elements look like (HOST PROP1 VAL1 PROP2 VAL2 ...) +HOST is the name of an LDAP server. PROPn and VALn are property/value pairs +describing parameters for the server. Valid properties: `binddn' is the distinguished name of the user to bind as (in RFC 1779 syntax). `passwd' is the password to use for simple authentication. @@ -85,87 +55,27 @@ `scope' is one of the three symbols `subtree', `base' or `onelevel'. `deref' is one of the symbols `never', `always', `search' or `find'. `timelimit' is the timeout limit for the connection in seconds. - `sizelimit' is the maximum number of matches to return." - :type '(repeat :menu-tag "Host parameters" - :tag "Host parameters" - (list :menu-tag "Host parameters" - :tag "Host parameters" - :value nil - (string :tag "Host name") - (checklist :inline t - :greedy t - (list - :tag "Search Base" - :inline t - (const :tag "Search Base" base) - string) - (list - :tag "Binding DN" - :inline t - (const :tag "Binding DN" binddn) - string) - (list - :tag "Password" - :inline t - (const :tag "Password" passwd) - string) - (list - :tag "Authentication Method" - :inline t - (const :tag "Authentication Method" auth) - (choice - (const :menu-tag "None" :tag "None" nil) - (const :menu-tag "Simple" :tag "Simple" simple) - (const :menu-tag "Kerberos 4.1" :tag "Kerberos 4.1" krbv41) - (const :menu-tag "Kerberos 4.2" :tag "Kerberos 4.2" krbv42))) - (list - :tag "Search Scope" - :inline t - (const :tag "Search Scope" scope) - (choice - (const :menu-tag "Default" :tag "Default" nil) - (const :menu-tag "Subtree" :tag "Subtree" subtree) - (const :menu-tag "Base" :tag "Base" base) - (const :menu-tag "One Level" :tag "One Level" onelevel))) - (list - :tag "Dereferencing" - :inline t - (const :tag "Dereferencing" deref) - (choice - (const :menu-tag "Default" :tag "Default" nil) - (const :menu-tag "Never" :tag "Never" never) - (const :menu-tag "Always" :tag "Always" always) - (const :menu-tag "When searching" :tag "When searching" search) - (const :menu-tag "When locating base" :tag "When locating base" find))) - (list - :tag "Time Limit" - :inline t - (const :tag "Time Limit" timelimit) - (integer :tag "(in seconds)")) - (list - :tag "Size Limit" - :inline t - (const :tag "Size Limit" sizelimit) - (integer :tag "(number of records)"))))) -:group 'ldap) + `sizelimit' is the maximum number of matches to return." ) + (defun ldap-search (filter &optional host attributes attrsonly) "Perform an LDAP search. -FILTER is the search filter in RFC1558 syntax, i.e., something that -looks like \"(cn=John Smith)\". -HOST is the LDAP host on which to perform the search. -ATTRIBUTES is a list of attributes to retrieve; nil means retrieve all. -If ATTRSONLY is non nil, the attributes will be retrieved without +FILTER is the search filter in RFC1558 syntax +HOST is the LDAP host on which to perform the search +ATTRIBUTES is a list of the specific attributes to retrieve, +nil means retrieve all +ATTRSONLY if non nil retrieves the attributes only without the associated values. Additional search parameters can be specified through `ldap-host-parameters-alist' which see." (interactive "sFilter:") - (or host - (setq host ldap-default-host) - (error "No LDAP host specified")) - (let ((host-plist (cdr (assoc host ldap-host-parameters-alist))) - ldap - res) + (let (host-plist res ldap) + (if (null host) + (setq host ldap-default-host)) + (if (null host) + (error "No LDAP host specified")) + (setq host-plist + (cdr (assoc host ldap-host-parameters-alist))) (message "Opening LDAP connection to %s..." host) (setq ldap (ldap-open host host-plist)) (message "Searching with LDAP on %s..." host) @@ -176,6 +86,7 @@ (ldap-close ldap) res)) + (provide 'ldap)