====== Rubrica LDAP per Mozilla Thunderbird ====== Il supporto alla rubrica LDAP in Thunderbird è purtroppo in **sola lettura**, tuttavia ha i suoi vantaggi. Qui configuriamo il database LDAP in **sola lettura per l'utente guest** e in lettura/scrittura per un utente admin. Il server LDAP è una Debian GNU/Linux Lenny. Se LDAP viene già usato per altri scopi (ed esempio autenticazione e NSS), si crea **un secondo database** destinato a contenere l'addressbook. Purtroppo non esiste uno standard ben definito di **schema LDAP** da utilizzare, il diffuso **InetOrgPerson** (RFC2798) non si adatta al contenuto di una moderna rubrica, pertanto alla Mozilla hanno pensato bene di creare lo schema **mozillaAbPersonAlpha** (Mozilla Addressbook Person), ancora in fase di sviluppo, ma ben supportato da Thunderbird. ===== Configurazione di slapd ===== Nel file **''/etc/ldap/slapd.conf''** si include lo schema ''mozillaAbPersonAlpha'' (prelevato dal [[https://wiki.mozilla.org/MailNews:Mozilla_LDAP_Address_Book_Schema|Mozilla Wiki]] e salvato in ''/etc/ldap/schema/'', {{.:ldap:mozillaabpersonalpha.schema.gz|qui una copia}} salvata in data 2008-12-08): include /etc/ldap/schema/mozillaabpersonalpha.schema e si aggiunge una sezione database in fondo al file: ####################################################################### # Specific Directives for database #2, of type 'other' (can be hdb too): # Database specific directives apply to this databasse until another # 'database' directive occurs database hdb # The base of your directory for database #2 suffix "ou=Addressbook,dc=rigacci,dc=org" rootdn "cn=admin,ou=Addressbook,dc=rigacci,dc=org" rootpw "MySecret" # Where the database file are physically stored for database #2 directory "/var/lib/ldap/abook" # The dbconfig settings are used to generate a DB_CONFIG file the first # time slapd starts. They do NOT override existing an existing DB_CONFIG # file. You should therefore change these settings in DB_CONFIG directly # or remove DB_CONFIG and restart slapd for changes to take effect. # For the Debian package we use 2MB as default but be sure to update this # value if you have plenty of RAM dbconfig set_cachesize 0 2097152 0 # Number of objects that can be locked at the same time. dbconfig set_lk_max_objects 1500 # Number of locks (both requested and granted) dbconfig set_lk_max_locks 1500 # Number of lockers dbconfig set_lk_max_lockers 1500 # Indexing options for database #22 index objectClass eq index cn,givenName,mail,sn eq,sub # Save the time that the entry gets modified, for database #2 lastmod on # Checkpoint the BerkeleyDB database periodically in case of system # failure and to speed slapd shutdown. checkpoint 512 30 # Full access to admin, read-only to everyone. access to * by dn="cn=admin,ou=Addressbook,dc=rigacci,dc=org" write by anonymous auth by * read La clausola **''by anonymous auth''** impedisce che utenti anonimi possano leggere il database, ma consente agli stessi di autenticarsi. Fare attenzione a non causare conflitti con i database LDAP già esistenti. In particolare l'opzione **''directory''** deve puntare ad una directory diversa da quelle già in uso e **''suffix''** deve essere un ramo distinto da quelli esistenti (non può essere ugugale né può essere un figlio). È necessario creare la sottodirectory per contenere i file LDAP e riavviare il demone: mkdir /var/lib/ldap/abook chown openldap:openldap /var/lib/ldap/abook chmod 0700 /var/lib/ldap/abook /etc/init.d/slapd restart Come si vede **l'utente admin** e la relativa **password** sono memorizzate in chiaro direttamente nel file di configurazione, se si desidera inserire la password in forma criptata aiutarsi con il programma **''slappasswd''**. L'utente **guest** e tutte le voci della rubrica saranno inserite nel database LDAP. ===== Popolazione del database ===== Per popolare il database si creano alcuni file .ldif che verranno caricati con ''ldapadd''. Anzitutto la radice del database: dn: ou=Addressbook,dc=rigacci,dc=org objectClass: top objectClass: organizationalUnit ou: Addressbook Poi l'utente **guest** che verrà usato per accedere in sola lettura: dn: cn=guest,ou=Addressbook,dc=rigacci,dc=org objectclass: top objectclass: person objectclass: organizationalPerson objectclass: inetOrgPerson sn: guest cn: guest userPassword: guest Infine una entry di esempio: dn: cn=Niccolò Rigacci,ou=Addressbook,dc=rigacci,dc=org objectclass: top objectclass: person objectclass: organizationalPerson objectclass: inetOrgPerson objectclass: mozillaAbPersonAlpha givenName: Niccolò sn: Rigacci cn: Niccolò Rigacci mail: niccolo@rigacci.org homePhone: 055-898989 mobile: 338-81818181 Per caricare i file (nell'ordine visto) si usano comandi del tipo: ldapadd -x -W -D "cn=admin,dc=rigacci,dc=org" -f file.ldif Nella pagina [[http://www.mozilla.org/projects/thunderbird/specs/ldap.html|LDAP in Mozilla Thunderbird]] viene riporata la corrispondenza tra attributi LDAP e i campi rubrica di Thunderbird: ^ Address Book Attribute ^ LDAP Property ^ | FirstName | givenname | | LastName | sn | | LastName | surname | | DisplayName | cn | | DisplayName | commonname | | DisplayName | displayname | | NickName | xmozillanickname | | PrimaryEmail | mail | | SecondEmail | xmozillasecondemail | | WorkPhone | telephonenumber | | HomePhone | homephone | | FaxNumber | fax | | FaxNumber | facsimiletelephonenumber | | PagerNumber | pager | | PagerNumber | pagerphone | | CellularNumber | mobile | | CellularNumber | cellphone | | CellularNumber | carphone | | WorkAddress | postofficebox | | WorkAddress | streetaddress | | WorkCity | l | | WorkCity | locality | | WorkState | st | | WorkState | region | | WorkZipCode | postalcode | | WorkZipCode | zip | | WorkCountry | countryname | | JobTitle | title | | Department | ou | | Department | orgunit | | Department | department | | Department | departmentnumber | | Company | o | | Company | company | | WorkCountry | countryname | | _AimScreenName | nscpaimscreenname | | WebPage1 | workurl | | WebPage2 | homeurl | | BirthYear | birthyear | | Custom1 | custom1 | | Custom2 | custom2 | | Custom3 | custom3 | | Custom4 | custom4 | | Notes | notes | | Notes | description | | PreferMailFormat | xmozillausehtmlmail | | LastModifiedDate | modifytimestamp | ===== Dump del database ===== Sul server che ospita il database, l'utente root può usare **''slapcat''**. Poiché la rubrica è il secondo database LDAP definito nel file di configurazione, si usa slapcat -n 2 ===== Configurazione di Thunderbird ===== Dal menu //Edit// -> //Preferences// -> //Composition// -> //Addressing// -> //Edit Directories...// si devono inserire i parametri per il database LDAP: {{.:ldap:ldap_tb_server_properties.png?450|LDAP Directory Server Properties}} Abilitare anche l'opzione //Address Autocompletion//, in modo che funzioni il completamento automatico dell'indirizzo durante la digitazione del destinatario. La **ricerca** può essere fatta dalla **finestra della rubrica** selezionando dall'elenco a sinistra la rubrica LDAP e iniziando a digitare il nome nel riquadro in alto a destra. **Ricerche avanzate** si possono fare dal menu //Edit// -> //Search Addresses...//, impostando criteri per ciascun singolo campo (nome, ditta, ecc.). ===== Gestione rubrica su web ===== In attesa che Thunderbird abbia il supporto in lettura/scrittura su LDAP, possiamo usare un semplice applicativo web per editare la rubrica. Su Sourceforge abbiamo **[[http://sourceforge.net/projects/abldap/|ABLdap]]**, un **LDAP Address Book editor**, in **PHP**, che supporta lo **schema mozillaAbPersonAlpha**. Semplicissimo da installare, localizzato in inglese e italiano.