* ldap.el Problem and Solution
@ 2012-10-24 14:48 Noah Lavine
2012-10-24 18:58 ` Noah Lavine
2012-10-29 10:58 ` Chong Yidong
0 siblings, 2 replies; 4+ messages in thread
From: Noah Lavine @ 2012-10-24 14:48 UTC (permalink / raw)
To: emacs-devel
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: ..........
<attribute>: <value>
<attribute>: <value>
.... 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: .........
<attribute>: <value>
.... 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ldap.el Problem and Solution
2012-10-24 14:48 ldap.el Problem and Solution Noah Lavine
@ 2012-10-24 18:58 ` Noah Lavine
2012-10-29 10:58 ` Chong Yidong
1 sibling, 0 replies; 4+ messages in thread
From: Noah Lavine @ 2012-10-24 18:58 UTC (permalink / raw)
To: emacs-devel
Replying to myself, I found out that the "version:" header is actually
required by RFC 2849, which defines LDIF (the LDAP Data Interchange
Format). So trying to change my 'ldapsearch' program to omit it is
definitely not the right approach here.
The solution I posted earlier would work, but to be even more careful,
the parser could throw an error if it saw "version: " followed by an
integer greater than 1, because it doesn't know how to parse that.
However, that seems very unlikely, given that this RFC has lasted
since the year 2000 without revisions.
Thanks,
Noah Lavine
On Wed, Oct 24, 2012 at 10:48 AM, Noah Lavine <noah.b.lavine@gmail.com> wrote:
> 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: ..........
> <attribute>: <value>
> <attribute>: <value>
> .... 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: .........
> <attribute>: <value>
> .... 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ldap.el Problem and Solution
2012-10-24 14:48 ldap.el Problem and Solution Noah Lavine
2012-10-24 18:58 ` Noah Lavine
@ 2012-10-29 10:58 ` Chong Yidong
2012-10-29 19:49 ` Noah Lavine
1 sibling, 1 reply; 4+ messages in thread
From: Chong Yidong @ 2012-10-29 10:58 UTC (permalink / raw)
To: Noah Lavine; +Cc: emacs-devel
Noah Lavine <noah.b.lavine@gmail.com> writes:
> 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.
Please send a patch, preferably against current trunk. Line 579 of
ldap.el, on trunk, doesn't seem to be the spot you intended.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ldap.el Problem and Solution
2012-10-29 10:58 ` Chong Yidong
@ 2012-10-29 19:49 ` Noah Lavine
0 siblings, 0 replies; 4+ messages in thread
From: Noah Lavine @ 2012-10-29 19:49 UTC (permalink / raw)
To: Chong Yidong; +Cc: emacs-devel
You're right; line 579 makes no sense.
Stefan already installed the fix at line 607 of ldap.el, where it
belongs, so I don't think a patch would be useful here; but in the
future I will try to make sure that I provide a patch against the
trunk.
Thanks,
Noah
On Mon, Oct 29, 2012 at 6:58 AM, Chong Yidong <cyd@gnu.org> wrote:
> Noah Lavine <noah.b.lavine@gmail.com> writes:
>
>> 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.
>
> Please send a patch, preferably against current trunk. Line 579 of
> ldap.el, on trunk, doesn't seem to be the spot you intended.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-10-29 19:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-24 14:48 ldap.el Problem and Solution Noah Lavine
2012-10-24 18:58 ` Noah Lavine
2012-10-29 10:58 ` Chong Yidong
2012-10-29 19:49 ` Noah Lavine
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).