📜 ⬆️ ⬇️

Address book on OpenLDAP for Outlook

Introduction


The company has a file with contacts of employees, filled by the hands of the manager. You need to make it a synchronized address book with addresses and attendances for your email program - MS Outlook, The Bat, Mozilla Thunderbird, etc.

I really want it to be compatible with “show the entire list” in Outlook, without a filter.

Cut the task into 4 parts:


Openldap


Due to the frivolous handling of standards by Microsoft, we have an incompatibility of displaying all the addresses in the address book. Since the mountain doesn’t go to Muhammad, you’ll have to tweak OpenLDAP a bit.
')
Victor Sudakov did a great job with the patch here , for which he thanks a lot for admin.

As an OS on the server, which can easily be virtual, say, with an 8Gb disk and 64Mb of memory, there is CSS - Calculate Linux Scratch (Gentoo, in one word), for which you can make your patch easily and naturally.

Pachim


Retreat for those who do not want to engage in bloody patching - just connect my test turnips (not the fact that I will update it): Add overlay to /etc/layman/layman.cfg:

overlays : http://www.gentoo.org/proj/en/overlays/repositories.xml https://raw.github.com/arrrght/openldap-outlook/master/overlay.xml 


Activate and sync:
 # layman -S # layman -a openldap-outlook 


We write the keys in /etc/portage/package.use:
net-nds/openldap experimental icu slp perl overlays ms-sssvlv

Install OpenLDAP
 emerge openldap 


For those who love to do everything with their hands, here is the patch (taken here ):
 --- ./openldap-2.4.33/servers/slapd/schema_prep.c.orig 2012-12-07 09:54:56.000000000 +0700 +++ ./openldap-2.4.33/servers/slapd/schema_prep.c 2012-12-07 09:58:10.000000000 +0700 @@ -908,6 +908,7 @@ "DESC 'RFC4519: common supertype of name attributes' " "EQUALITY caseIgnoreMatch " "SUBSTR caseIgnoreSubstringsMatch " + "ORDERING caseIgnoreOrderingMatch " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )", NULL, SLAP_AT_ABSTRACT, NULL, NULL, 


Customization


The most correct setting is written here - this is just for those who decide to seriously engage in LDAP. In my case, everything is easier - I just need an address book. I left almost everything by default in the /etc/openldap/slapd.conf file. Here it is, entirely, without any indexes, and in general, a lot of extras:

 include /etc/openldap/schema/core.schema include /etc/openldap/schema/cosine.schema include /etc/openldap/schema/inetorgperson.schema include /etc/openldap/schema/java.schema include /etc/openldap/schema/openldap.schema include /etc/openldap/schema/nis.schema include /etc/openldap/schema/corba.schema include /etc/openldap/schema/dyngroup.schema include /etc/openldap/schema/misc.schema include /etc/openldap/schema/pmi.schema pidfile /var/run/openldap/slapd.pid argsfile /var/run/openldap/slapd.args modulepath /usr/lib64/openldap/openldap moduleload back_passwd.so moduleload back_ldap.so moduleload sssvlv.so database hdb overlay sssvlv suffix "dc=org,dc=com" checkpoint 32 30 rootdn "cn=Manager,dc=org,dc=com" rootpw secret directory /var/lib/openldap-data index objectClass eq   ,  ,    LDAP   entry.ldif: dn: dc=org,dc=com objectClass: dcObject objectClass: organization o: org.com</code>   ldif  : <code>slapadd < entry.ldif</code>    LdapAdmin     ou=ab,dc=org,dc=com. ,  ,      . <h4>XLS</h4>      smbget,    samba,   xls2csv.          getfile.sh: <source lang="bash"> #!/bin/sh SMBGET=/usr/bin/smbget LDAPSEARCH=/usr/bin/ldapsearch LDAPDELETE=/usr/bin/ldapdelete rm "temp.xls" ${SMBGET} "smb://domain;user:password@192.168.1.1/Share/Telephones.xls" -o temp.xls xls2csv -c~ -b\' temp.xls > temp.csv # delete all from ou=ab,dc=org,dc=com ${LDAPSEARCH} -b "ou=ab,dc=org,dc=com" "(uid=*)" | grep dn: | awk '{print $2}' | ${LDAPDELETE} -Dcn=Manager,dc=org,dc=com -wsecret 


Further the pearl-barley script transforming csv into the necessary ldif file, approximately such (it is written in a hurry):

 #!/usr/bin/perl use strict; use encoding 'utf8'; open my $fh, "<temp.csv" or die 'Can\'t open file'; open my $fout, ">temp.ldif" or die 'Can\'t write to file'; my $org = ''; my $orgNum = 0; my $div = ''; my $userNum = 1000; my $ouDcDc = 'ou=ab,dc=org,dc=com'; while (my $line = <$fh>) { my $isNowOrg = 0; my $email = ''; chomp $line; my @f = split /~/, $line; if (!$org || $f[0]=~/\'/){ $org = clean($f[0]); $org =~s/^(.+)\"(.+)\"$/$2/; $org = firstUp($org); $isNowOrg = 1; $orgNum++; } $email = clean($f[5]) if $f[5]=~/@/; $div = firstUp(clean($f[0])) unless $f[1] || $email; my $name = clean($f[1]); my $post = clean($f[0]); my $telNum = clean($f[4]); $telNum =clean($f[2]) if $orgNum==3; $telNum =~s/\D/ /g; $telNum =~s/^\D*//g; #print "#$telNum#\n"; #$telNum = ~s/\W//g; my %names = givenName($name); if ($name && $post && $names{'firstName'}){ ++$userNum; print $fout "dn: uid=user${userNum},${ouDcDc}\n"; print $fout "uid: user${userNum}\n"; print $fout "objectClass: posixAccount\nobjectClass: top\nobjectClass: inetOrgPerson\ngidNumber: 1000\n"; print $fout "uidNumber: ${userNum}\n"; print $fout "givenName: ", $names{'firstName'}, "\n"; print $fout "initials: ", $names{'middleName'}, "\n"; print $fout "sn: ", $names{'lastName'}, "\n"; #print $fout "username: user${userNum}\n"; print $fout "homeDirectory: home_dir\ngecos: gecos\nloginShell: log_shell\n"; print $fout "telephoneNumber: ${telNum}\n" if $telNum; print $fout "physicalDeliveryOfficeName: ${div}\n"; print $fout "ou: ${div}\n"; print $fout "o: $org\n"; #print $fout "organizationName: ACME\n"; print $fout "title: $post\n"; print $fout "mail: $email\n"; print $fout "cn: ", $names{'shortName'},"\n"; print $fout "\n"; # print "ORG: $org, DIV: $div, POST: $post, NAME: $name, EMAIL: $email\n"; } } close $fout; close $fh; sub givenName(){ my $name = shift; my @s=[]; my %names = {}; @s = split ' ', $name; $names{'firstName'} = $s[1]; $names{'lastName'} = $s[0]; $names{'middleName'} = $s[2]; $names{'shortName'} = $s[0] .' '. substr($s[1],0,1) .'.'. substr($s[2],0,1) .'.'; return %names; } sub clean(){ my $name = shift; $name =~s/^\'//; $name =~s/\"\"/\"/g; $name =~s/^\"//; $name =~s/\"$//; $name =~s/\ *$//g; $name =~s/\ +/\ /g; return $name; } sub firstUp(){ my $name = shift; $name = lc($name); return ucfirst($name); } 

After that, the output should be temp.ldif, which we already feed to the command

 ldapadd -v -Dcn=Manager,dc=org,dc=com -wsecret < ./temp.ldif 


That somehow with the server part. On the client, in Outlook, we do:

    -->   -->  --> LDAP--> IP:  IP        -->  -->  : ou=ab,dc=org,dc=com :   (  ) 


Everything. We check, we register in kroner, we optimize.
PS: In order to display the organization in the Olook address list, you need to patch the /etc/openldap/schema/core.schema file: Add 'company' - thanks to Microsoft for not paying attention to the standard o entry, line 120
 attributetype ( 2.5.4.10 NAME ( 'company' 'o' 'organizationName' ) DESC 'RFC2256: organization this object belongs to' SUP name ) 


** Copy-paste from my site a3r.me/posts/openldap-outlook.html

Source: https://habr.com/ru/post/183996/


All Articles