Address book customisation. Add column from AD

Hello!
Our company uses AD and Exchange. We used to Outlook as our email client, but now we have switched to Evolution.
I have a question for more experienced Evolution users. Is there any way I can customize the address book? I would like the FullName field to contain First Name, Last Name and AD ExtenssionAttribute1

For example
instead of Nikolai Gogol
became Nikolai Vasilyevich Gogol

1 Like

Hi,
as you mention AD, do you connect the address book using LDAP or
anything else?

The evolution-data-server provides an extension to the LDAP schema [1],
which you can install on the server and modify the things as you’d like
to. I do not know LDAP that closely to tell you whether it’s of any use
for you or not, I’m sorry.

Otherwise there is nothing for this. Custom (extension) attributes are
just that, custom. The apps may or may not know about them. Being it
standard attributes the apps should know about them.
Bye,
Milan

[1] src/addressbook/backends/ldap/evolutionperson.schema · master · GNOME / evolution-data-server · GitLab

Thank you for your detailed and prompt reply!

We connect to Exchange via EWS
We use the Global Addrees List. When sending messages and viewing the address book, the name is displayed in the format “Nikolai Gogol”. I really want to make a change to the FullName parameter. Expand its value if possible

Hi,
aha, EWS, that’s part of the “cannot do much without changing the code
due to custom value being used”. There’s a question whether the
Exchange server sends that attribute at all.

Do you have enabled Offline Address Book (OAB)? It’s in the mail
account Properties->Receiving Options tab. It works only if the OAB URL
on the Receiving Email tab is filled. The OAB contains much more
information than what is returned by the ResolveNames request. Change
in this setting might want restart of the evolution-addressbook-factory
process, to have the address book reload the data. You can do it from a
terminal when you run:

evolution --force-shutdown

which restarts more than just the address book factory process, but
it’s for good.

Bye,
Milan

Hello Milan!

Thank you! I really appreciate your attention!
I have checked the Evolution settings, namely receiving mail - the OAB URL is entered in the corresponding line.

As for passing the attribute - in Outlook (web version) it is displayed correctly, so I assume that it is the Evolution mail client that needs to be configured.

Hi,
okay, and on the Receiving Options tab, near the bottom, is the Offline
Address Book option selected?

Bye,
Milan

Thank you!

Now selected. Haven’t noticed any difference yet, I’ll try to tweak something now

Discovered this…
When I try to change a contact and click on the “Full Name…” button, the parameter I need (it is called “Middle”) is empty for some reason. Is it possible to solve this? Can it be filled from Exhange? If “Middle” will be an “ExtenssionAttribute1” it would solve the problems of my whole company.

I have filled in the “middleName” parameter in AD, but Evolution still does not display it. Has anyone encountered a similar problem? Maybe I’m doing something wrong?

Changing the address book to the offline version is tricky. The evolution-addressbook-factory process may not propagate the change properly (it’s evolution-ews’ fault).

Did you restart the machine or relogin since you made the change? What if you run from a terminal evolution --force-shutdown and then start evolution again? You can remove ~/.cache/evolution/addressbook/ before running the force-shutdown, to let the remote address books re-dowload the information from the books. You should see more details on the contact when the GAL is populated from the offline data. Whether the server maps the extension attribute to the middle name I do not know (I guess it doesn’t, but I can be wrong). You can alos right-0click the “Global Address List” book in the Contacts view and pick Refresh from the context menu, which will check whether a new version of the GAL is available and will download it if so. Only note the contact changes on the server take some time to be propagated in the GAL.

You can run the address book factory with EWS debugging on to see what it does. It’s like:

   EWS_DEBUG=1 /usr/libexec/evolution-addressbook-factory -w

and then run Evolution. Note the log contains raw communication between the Exchange server and the client, thus something you won’t share in the public. The actual path of the factory process can differ in your distro.

That was a great try! I’m very grateful! When using the offline address book cache - there are indeed differences, for example now I can see employee photos, before they were not displayed for everyone. Unfortunately, the MiddleName parameter is still not available, it’s probably my kryptonite. Anyway, thanks for your time, it’s great that there are caring people out there

I see the usual user contacts do read middle name from the EWS protocol attribute MiddleName, but I do not see reading it from the (offline) GAL. Maybe I overlooked something. Looking on the MAPI properties (which the GAL uses), I see there is PT_SURNAME and PT_GIVEN_NAME. The evolution-mapi (an old connector for even older servers) doesn’t read the middle name at all. There is a PidTagMiddleName tag, which might contain the value in the offline GAL.

Can I ask you whether you use a Fedora machine, and if not, would it be possible to install a virtual machine for some testing, please? I can provide a test build for Fedora to check whether the offline GAL has stored the middle name in a standard attribute, to verify whether it can be read from it. As it looks right now, the middle name is not read back for the offline GAL and the online contacts do not seem to map your custom attribute to the proper place. It means there would be needed two changes here:

  1. on the evolution-ews side to read the middle name from the offline GAL;
  2. on your server, to use the standard attribute.

I cannot map the attribute your company chose to the middle name, because other company can use the non-standard attribute for some other data, with different meaning, thus such change would break the things for them.

Wow! That sounds intriguing!
I will try to coordinate a Fedora install with my supervisor. It’s going to take me a while!
Thank you so much!

To be more precise, I will provide a test patch, which can be applied to any distro, the only advantage with Fedora is that I can provide also built package, thus saving you time with building and setting up the build environment.

I guess something like the below may do the trick. The Discourse doesn’t let me attach a text file, thus it’s inline (with broken whitespace, I believe). The debug prints are done on the evolution-addressbook-factory console.

diff --git a/src/EWS/addressbook/ews-oab-decoder.c b/src/EWS/addressbook/ews-oab-decoder.c
index 226e35fa..0ab731fd 100644
--- a/src/EWS/addressbook/ews-oab-decoder.c
+++ b/src/EWS/addressbook/ews-oab-decoder.c
@@ -96,6 +96,32 @@ ews_deffered_populate_physical_address (EwsDeferredSet *dset,
 	}
 }
 
+static void
+ews_populate_middle_name (EContact *contact,
+			  EContactField field,
+			  gpointer value,
+			  gpointer user_data)
+{
+	const gchar *str = (const gchar *) value;
+	if (str && *str) {
+		EContactName *name = e_contact_get (contact, field);
+		gchar *prev;
+
+		if (!name)
+			name = e_contact_name_new ();
+
+		prev = name->additional;
+		name->additional = (gchar *) str;
+
+		e_contact_set (contact, field, name);
+
+		name->additional = prev;
+		e_contact_name_free (name);
+
+		g_print ("%s: found middle name '%s'\n", __FUNCTION__, str); fflush (stdout);
+	}
+}
+
 static void
 ews_populate_phone_numbers (EContact *contact,
                             EContactField field,
@@ -255,6 +281,7 @@ static const struct prop_field_mapping {
 	{EWS_PT_ACCOUNT, E_CONTACT_NICKNAME, ews_populate_simple_string},
 	{EWS_PT_SURNAME, E_CONTACT_FAMILY_NAME, ews_populate_simple_string},
 	{EWS_PT_GIVEN_NAME, E_CONTACT_GIVEN_NAME, ews_populate_simple_string},
+	{EWS_PT_MIDDLE_NAME, E_CONTACT_NAME, ews_populate_middle_name},
 	{EWS_PT_BUS_TEL_NUMBER, E_CONTACT_PHONE_BUSINESS, ews_populate_simple_string},
 	{EWS_PT_STREET_ADDRESS, E_CONTACT_ADDRESS_WORK, NULL, ews_deffered_populate_physical_address},
 	{EWS_PT_LOCALITY, E_CONTACT_ADDRESS_WORK, NULL, ews_deffered_populate_physical_address},
diff --git a/src/EWS/addressbook/ews-oab-props.h b/src/EWS/addressbook/ews-oab-props.h
index 2516757d..6889d2bb 100644
--- a/src/EWS/addressbook/ews-oab-props.h
+++ b/src/EWS/addressbook/ews-oab-props.h
@@ -36,6 +36,7 @@
 #define	EWS_PT_ACCOUNT			0x3A00001F 
 #define EWS_PT_SURNAME			0x3A11001F
 #define EWS_PT_GIVEN_NAME		0x3A06001F
+#define EWS_PT_MIDDLE_NAME		0x3A44001F
 #define EWS_PT_OFFICE_LOCATION		0x3A19001F
 #define EWS_PT_BUS_TEL_NUMBER		0x3A08001F
 #define	EWS_PT_INITIALS			0x3A0A001F

Milan, good afternoon!
I must say I am honored and knocked off my feet by your willingness to help me! I’ve seen this kind of eagerness a long time ago, back in the days of ADSL modems, when people on forums were really trying to share experiences and do something nice/useful for someone else. To put it simply, it’s incredible!

Except that my knowledge is not enough, I don’t understand, at least now, how to apply the data from your previous answer. I have no idea how I can try it out

That’s okay. The change is at least saved here, thus it won’t vanish.

Let me know if you can install virtual machine with a Fedora Linux (the newer the better, thus at least Fedora 40, please), then tell me which version it is and I’ll create a test package for you, with instructions how to install it.

As a side note, I think it’s a valid bug that the evo-ews offline GAL does not read the middle name (might be filled at Issues · GNOME / evolution-ews · GitLab ideally), only either nobody noticed or nobody cared to fill it. Adding the read of it will improve the data for the all users.

Thank you! Got it now.

Right now I’m downloading a Fedora 40 image

If everything works out and the result is useful for someone else, that would be great! It’s a dream come true

The test build is here and it’ll disappear in two weeks or so, because it’s a test build. I can rebuild it, if needed.

Once you have installed the VM, run a terminal and get the latest version of everything in it:

   sudo dnf update

and then restart the machine. Then log in again, and run from a terminal:

   sudo dnf install https://kojipkgs.fedoraproject.org//work/tasks/7799/122937799/evolution-ews-3.52.4-1.1.fc40.x86_64.rpm https://kojipkgs.fedoraproject.org//work/tasks/7799/122937799/evolution-ews-langpacks-3.52.4-1.1.fc40.noarch.rpm

(it’s one long line). It should install also evolution package. Once it confirms the packages are installed, you can run Evolution, can be also from terminal with evolution command, and then configure your Exchange Web Services (EWS) account. Make sure you’ll click the “Fetch URL” button and it’ll fill the OAB URL and also enable the offline GAL on the second page.

If it won’t let you enable the offline GAL when creating the account, then finish the wizard and return to the mail account Properties (context menu on the account name in the folder tree of the Mail view) once you see your Mail folders. If done this way (I’m not sure the book factory will catch up on the change, thus just in case remove all directories under ~/.cache/evolution/addressbook/ and then run from a terminal evolution --force-shutdown, after which run Evolution again.

To check whether the things work as expected, aka whether you are using the offline GAL, you can look into one of the ~/.cache/evolution/addressbook/<account-UID>/ directories, where one may contain a file named Global Address List ... or some such. Mine is Global Address List-3.oab .