From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Fixing url-ldap.el Date: Fri, 08 Apr 2005 22:34:09 -0700 Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1113025144 10032 80.91.229.2 (9 Apr 2005 05:39:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 9 Apr 2005 05:39:04 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 09 07:39:01 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DK8gJ-0005rR-O8 for ged-emacs-devel@m.gmane.org; Sat, 09 Apr 2005 07:38:56 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DK8Fx-0007x8-Ux for ged-emacs-devel@m.gmane.org; Sat, 09 Apr 2005 01:11:41 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DK8FX-0007oj-6E for emacs-devel@gnu.org; Sat, 09 Apr 2005 01:11:15 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DK8FV-0007no-EW for emacs-devel@gnu.org; Sat, 09 Apr 2005 01:11:14 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DK8FU-0007mv-J2 for emacs-devel@gnu.org; Sat, 09 Apr 2005 01:11:12 -0400 Original-Received: from [171.67.16.138] (helo=smtp3.Stanford.EDU) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DK8ck-0005gY-HG for emacs-devel@gnu.org; Sat, 09 Apr 2005 01:35:14 -0400 Original-Received: from partenope.stanford.edu (partenope.Stanford.EDU [171.64.106.136]) by smtp3.Stanford.EDU (8.12.11/8.12.11) with ESMTP id j395YA1P017448 for ; Fri, 8 Apr 2005 22:34:10 -0700 Original-Received: from partenope.stanford.edu (localhost.localdomain [127.0.0.1]) by partenope.stanford.edu (8.12.8/8.12.5) with ESMTP id j395Y9ZA031096 for ; Fri, 8 Apr 2005 22:34:09 -0700 Original-Received: (from yidong@localhost) by partenope.stanford.edu (8.12.8/8.12.8/Submit) id j395Y9Tc031094; Fri, 8 Apr 2005 22:34:09 -0700 X-Authentication-Warning: partenope.stanford.edu: yidong set sender to cyd@stupidchicken.com using -f Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:35793 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:35793 This patch should fix the entry "Fix up url-ldap.el" in FOR-RELEASE. Could someone review it? *** c:/home/emacs/lisp/url/url-ldap.el~ Sat Apr 9 11:22:56 2005 --- c:/home/emacs/lisp/url/url-ldap.el Sat Apr 9 13:34:55 2005 *************** *** 1,5 **** ;;; url-ldap.el --- LDAP Uniform Resource Locator retrieval code ! ;; Copyright (c) 1998 - 1999, 2004 Free Software Foundation, Inc. ;; Keywords: comm, data, processes --- 1,5 ---- ;;; url-ldap.el --- LDAP Uniform Resource Locator retrieval code ! ;; Copyright (c) 1998, 1999, 2004, 2005 Free Software Foundation, Inc. ;; Keywords: comm, data, processes *************** *** 112,121 **** (format "JPEG Photo" (url-hexify-string (base64-encode-string data)))) - ;; FIXME: This needs sorting out for the Emacs LDAP functions, specifically - ;; calls of ldap-open, ldap-close, ldap-search-internal ;;;###autoload (defun url-ldap (url) (save-excursion (set-buffer (generate-new-buffer " *url-ldap*")) (setq url-current-object url) --- 112,126 ---- (format "JPEG Photo" (url-hexify-string (base64-encode-string data)))) ;;;###autoload (defun url-ldap (url) + "Perform the LDAP search specified by URL, and display the result. + URL can be a URL string, or a URL vector of the type returned by + `url-generic-parse-url'." + (if (stringp url) + (setq url (url-generic-parse-url (url-unhex-string url))) + (if (not (vectorp url)) + (error "Argument is not a valid URL"))) (save-excursion (set-buffer (generate-new-buffer " *url-ldap*")) (setq url-current-object url) *************** *** 142,151 **** (scope nil) (filter nil) (extensions nil) ! (connection nil) ! (results nil) ! (extract-dn (and (fboundp 'function-max-args) ! (= (function-max-args 'ldap-search-internal) 7)))) ;; Get rid of leading / (if (string-match "^/" data) --- 147,153 ---- (scope nil) (filter nil) (extensions nil) ! (results nil)) ;; Get rid of leading / (if (string-match "^/" data) *************** *** 163,169 **** scope (intern (url-unhex-string (or scope "base"))) filter (url-unhex-string (or filter "(objectClass=*)"))) ! (if (not (memq scope '(base one tree))) (error "Malformed LDAP URL: Unknown scope: %S" scope)) ;; Convert to the internal LDAP support scoping names. --- 165,171 ---- scope (intern (url-unhex-string (or scope "base"))) filter (url-unhex-string (or filter "(objectClass=*)"))) ! (if (not (memq scope '(base one sub))) (error "Malformed LDAP URL: Unknown scope: %S" scope)) ;; Convert to the internal LDAP support scoping names. *************** *** 188,199 **** (assoc "!bindname" extensions)))) ;; Now, let's actually do something with it. ! (setq connection (ldap-open host (if binddn (list 'binddn binddn))) ! results (if extract-dn ! (ldap-search-internal connection filter base-object scope attributes nil t) ! (ldap-search-internal connection filter base-object scope attributes nil))) ! ! (ldap-close connection) (insert "\n" " \n" " LDAP Search Results\n" --- 190,203 ---- (assoc "!bindname" extensions)))) ;; Now, let's actually do something with it. ! (setq results (ldap-search-internal ! (list 'host (concat host ":" (number-to-string port)) ! 'base base-object ! 'attributes attributes ! 'scope scope ! 'filter filter ! 'binddn binddn))) ! (insert "\n" " \n" " LDAP Search Results\n" *************** *** 205,212 **** (mapc (lambda (obj) (insert "
\n" " \n") - (if extract-dn - (insert " \n")) (mapc (lambda (attr) (if (= (length (cdr attr)) 1) ;; single match, easy --- 209,214 ---- *************** *** 225,231 **** "
\n") "" " \n"))) ! (if extract-dn (cdr obj) obj)) (insert "
" (car obj) "
\n")) results) --- 227,233 ---- "
\n") "" " \n"))) ! obj) (insert " \n")) results)