In the
ejabberd note
with authorization via LDAP, I described the main points on setting up the ejabberd server. In the note,
external authentication programs showed how to use an external program if the functionality of the built-in modules is not enough. Now add a search on business cards users.
Connecting modules
For a start, briefly about connecting modules. In the configuration of the virtual host (or in the global domain), an entry is created that looks like this:
{modules, [
{module1, [module_1 options]},
{module2, [module_2 options]}
]},
In this record, you need to list the necessary modules with parameters.
The list of modules and parameters can be found in the same
ejabberd manual .
')
Now in my modules are configured as:
{modules, [
{mod_last, []},
{mod_offline, []}
]}
Support extensions
XEP-0030: Service Discovery - search services. Without this module, customers will not be able to find out which services we offer:
{modules, [
{mod_last, []},
{mod_offline, []},
{mod_disco, []}
]}
Supports
XEP-0054 expansion
: vCards - electronic business cards. The module allows you to receive from LDAP information about the name, surname, e-mail and so on (everything is configured) for each user. Its separate advantage is that it works even if authorization other than ldap is used. That is, I can authenticate users with my own program, and still retrieve useful information from LDAP.
{modules, [
{mod_last, []},
{mod_offline, []},
{mod_disco, []},
{mod_vcard_ldap, [
% Here I will write options
]}
]}
If LDAP authentication is used, the following options may be omitted. Their mod_vcard_ldap values will be taken from those specified earlier. However, if you specify them clearly, it will not be worse.
{ldap_servers, ["ldap.company.local"]},
{ldap_port, 389},
{ldap_base, "ou = people, dc = company, dc = local"},
{ldap_filter, "(gidNumber = 100)"},
The description of this option was already in
ejabberd with authorization through LDAP .
Below is a simple example of further configuration. Only the most basic properties are used.
% Set mappings between vCard fields and LDAP attributes
{ldap_vcard_map, [
{"NICKNAME", "% u", []},
{"GIVEN", "% s", ["givenName"]},
{"FAMILY", "% s", ["sn"]},
{"FN", "% s% s", ["givenName", "sn"]},
{"EMAIL", "% s", ["mail"]}
]},
% Define fields for searching by cards and their correspondence to attributes of LDAP accounts
{ldap_search_fields, [
{"User", "% u"},
{"Name", "givenName"},
{"Family Name", "sn"},
{"Email", "mail"}
]},
% Specify which vCard fields should be shown in search results
{ldap_search_reported, [
{"Full Name", "FN"},
{"Nickname", "NICKNAME"}
]}
Restart ejabberd. And
here you can check the result. Or use a client, for example Psi:
And search by card:
