<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Ldap on Major Hayden</title><link>https://major.io/tags/ldap/</link><description>Recent content in Ldap on Major Hayden</description><generator>Hugo</generator><language>en</language><managingEditor>major@mhtx.net (Major Hayden)</managingEditor><webMaster>major@mhtx.net (Major Hayden)</webMaster><copyright>All content licensed [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)</copyright><lastBuildDate>Sun, 07 Jun 2026 23:39:03 +0000</lastBuildDate><atom:link href="https://major.io/tags/ldap/index.xml" rel="self" type="application/rss+xml"/><item><title>Customize LDAP autocompletion format in Thunderbird</title><link>https://major.io/p/customize-ldap-autocompletion-format-in-thunderbird/</link><pubDate>Tue, 18 Jul 2017 18:08:42 +0000</pubDate><author>major@mhtx.net (Major Hayden)</author><guid>https://major.io/p/customize-ldap-autocompletion-format-in-thunderbird/</guid><description>&lt;p&gt;Thunderbird can connect to an LDAP server and autocomplete email addresses as you type, but it needs some adjustment for some LDAP servers. One of the LDAP servers that I use regularly returns email addresses like this in the thunderbird interface:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;username &amp;lt;firstname.lastname@domain.tld&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The email address looks fine, but I&amp;rsquo;d much rather have the person&amp;rsquo;s full name instead of the username. Here&amp;rsquo;s what I&amp;rsquo;m looking for:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Firstname Lastname &amp;lt;firstname.lastname@domain.tld&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In older Thunderbird versions, setting &lt;code&gt;ldap_2.servers.SERVER_NAME.autoComplete.nameFormat&lt;/code&gt; to &lt;code&gt;displayName&lt;/code&gt; was enough. However, this option isn&amp;rsquo;t used in recent versions of Thunderbird.&lt;/p&gt;
&lt;h2 id="digging-in"&gt;Digging in&lt;/h2&gt;
&lt;p&gt;After a fair amount of searching the Thunderbird source code with &lt;code&gt;awk&lt;/code&gt;, I found a mention of &lt;code&gt;DisplayName&lt;/code&gt; in &lt;code&gt;nsAbLDAPAutoCompleteSearch.js&lt;/code&gt; that looked promising:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-javascript" data-lang="javascript"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// Create a minimal map just for the display name and primary email.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_attributes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;Components&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;@mozilla.org/addressbook/ldap-attribute-map;1&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createInstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Components&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;interfaces&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nsIAbLDAPAttributeMap&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_attributes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttributeList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;DisplayName&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;attributeMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getAttributeList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;DisplayName&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{}),&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_attributes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttributeList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;PrimaryEmail&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;attributeMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getAttributeList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;PrimaryEmail&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{}),&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Something is unusual here. The LDAP field is called &lt;code&gt;displayName&lt;/code&gt;, but this attribute is called &lt;code&gt;DisplayName&lt;/code&gt; (note the capitalization of the &lt;em&gt;D&lt;/em&gt;). Just before that line, I see a lookup in an attributes map of some sort. There may be a configuration option that is called &lt;code&gt;DisplayName&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In Thunderbird, I selected &lt;strong&gt;Edit &amp;gt; Preferences&lt;/strong&gt;. I clicked the &lt;strong&gt;Advanced&lt;/strong&gt; tab and then &lt;strong&gt;Config Editor&lt;/strong&gt;. A quick search for &lt;em&gt;DisplayName&lt;/em&gt; revealed an interesting configuration option:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;ldap_2.servers.default.attrmap.DisplayName: cn,commonname
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="fixing-it"&gt;Fixing it&lt;/h2&gt;
&lt;p&gt;That&amp;rsquo;s the problem! This needs to map to &lt;code&gt;displayName&lt;/code&gt; in my case, and not &lt;code&gt;cn,commonname&lt;/code&gt; (which returns a user&amp;rsquo;s username). There are two different ways to fix this:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;# Change it for just one LDAP server
ldap_2.servers.SERVER_NAME.attrmap.DisplayName: displayName
# Change it for all LDAP servers by default (careful)
ldap_2.servers.default.attrmap.DisplayName: displayName
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;After making the change, quit Thunderbird and relaunch it. Compose a new email and start typing in the email address field. The user&amp;rsquo;s first and last name should appear!&lt;/p&gt;</description></item></channel></rss>