From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Noah Lavine Newsgroups: gmane.emacs.devel Subject: ldap.el Problem and Solution Date: Wed, 24 Oct 2012 10:48:40 -0400 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1351090142 7786 80.91.229.3 (24 Oct 2012 14:49:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 24 Oct 2012 14:49:02 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 24 16:49:10 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TR2GY-0007WC-O1 for ged-emacs-devel@m.gmane.org; Wed, 24 Oct 2012 16:49:06 +0200 Original-Received: from localhost ([::1]:45915 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TR2GQ-0004AW-V4 for ged-emacs-devel@m.gmane.org; Wed, 24 Oct 2012 10:48:58 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TR2GH-00047v-NR for emacs-devel@gnu.org; Wed, 24 Oct 2012 10:48:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TR2GA-0001ug-Bq for emacs-devel@gnu.org; Wed, 24 Oct 2012 10:48:49 -0400 Original-Received: from mail-ob0-f169.google.com ([209.85.214.169]:55701) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TR2GA-0001ty-31 for emacs-devel@gnu.org; Wed, 24 Oct 2012 10:48:42 -0400 Original-Received: by mail-ob0-f169.google.com with SMTP id va7so616994obc.0 for ; Wed, 24 Oct 2012 07:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; bh=LjoXIIh3YGapwLI60UIKsyV/97RH9dIb5WwsuQ5+zbM=; b=cKeHfOuiChHyYAoK/zh0JcQAUBlbGB6Dl+Vfb3PWgIlXYOeFXzWR/+xFtvz09wUKGF 8wIqWEInfUf8mDjms3o8UzCYYKTv/Pssu56xTeT+cwPf9rIkBsZp6DVLChcke5abMijK EvF+ZGZVVpIAGBM6AQvUwKUSKAu9q24K6bHRSBFrSbrX5JCk0OGSftqw6sVPt3Df/2mT iQBWE29PcbivcPRCcYUUGY3Ek6T2U+DabufMPR+dX+wucfYVQqHqX0htNa1wZGeWtuW1 myzk2V+wDXpCW+da4yAiT/m6mcDupFNjEPr3XENm8gNIH22o5XFZh8pJC9I7QN3dDmAx n66A== Original-Received: by 10.182.177.100 with SMTP id cp4mr13265640obc.71.1351090120988; Wed, 24 Oct 2012 07:48:40 -0700 (PDT) Original-Received: by 10.76.120.236 with HTTP; Wed, 24 Oct 2012 07:48:40 -0700 (PDT) X-Google-Sender-Auth: HMD7VPSnPncrMSTRMizdJDuErBM X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:154491 Archived-At: Hello, I recently hit a problem in which ldap-search (in ldap.el) would return a list of records where the first record would always be nil. As far as I can tell, the rest of the list was correct; it just had an extra nil in the beginning. After some debugging, I think the issue is that my ldapsearch program (from OpenLDAP) doesn't quite use the output format ldap.el expects. The expected format is dn: .......... : : .... more attributes here ...... This is the ldif format, which seems to be standardized. But tragically, my ldapsearch program prints a header, which makes the results look like this: version: 1 dn: ......... : .... more attributes ..... This confuses the ldap.el parsing. I can tell this is the problem because when I step through in the debugger, the "dn" variable is set to "version: 1", instead of the obviously correct value. Then when it attempts to parse its results it finds an empty record, and so pushes 'nil onto its results list, which is what causes the problem. The solution is to insert this after line 579 of ldap.el: (if (looking-at "version:") (forward-line 1)) I have tested this, and it seems to work for me. The other option is to make the ldapsearch program not print its version header, but looking at its man page, I don't see a way to do that. If this solution doesn't seem good, I am happy to try a different approach, but it seems like the easiest solution to me. I have already signed copyright papers, although for a change as small as this they might not even be needed. Thanks, Noah Lavine