Old:Samba e OpenLDAP: creare un controller di dominio con Ubuntu Server

Debian-swirl.png Versioni Compatibili

ERRORE: valore non valido ( Ubuntu Server 10.04 LTS )! Vedi qui.



Versioni gnu/linux testate

  • Ubuntu Server 10.04 LTS

Introduzione

Questa Guida è un aggiornamento e un miglioramento della precedente Samba e OpenLDAP: creare un controller di dominio con Debian Lenny, basata su Debian Lenny.
Vedremo questa volta come configurare interamente un server PDC samba con backend LDAP basato su Ubuntu Server 10.04 LTS, affinché funga da Primary Domain Controller di una rete Windows. Lo stesso server LDAP verrà utilizzato anche per la gestione in contemporanea degli utenti Unix, in modo da avere un controllo unico e centralizzato sia sugli utenti Windows sia sugli utenti Linux.
Verranno illustrati due metodi di gestione del database LDAP, uno basato sui tools smbldap-tools e uno basato su interfaccia grafica in PHP.
Consiglio vivamente di prepararsi una buona tazza di caffé e di armarsi di pazienza e di molta attenzione, dato che un errore di battitura in qualche file di configurazione può mandare in rovina l'intero lavoro: poichè che i files da modificare saranno molti, di certo risulterebbe molto difficile e molto lungo andare a caccia di eventuali errori.

Sistema installato e prerequisiti

Il presente HOWTO è stato testato utilizzando un sistema Ubuntu Server 10.04 LTS con tutti gli aggiornamenti di sicurezza ufficiali. La versioni di Samba utilizzata è 3.4.7 e la versione di OpenLdap utilizzata è la 2.4.21. Durante tutto il processo di configurazione si presuppone di agire come utente "root", perciò verrà omesso il comando "sudo".

Parametri di rete utilizzati

In tutta la guida saranno utilizzati i seguenti parametri per la configurazione della rete:

* Nome del server: server
* Nome del dominio: dominio.local
* Nome NETBIOS del dominio: DOMINIO
* Classe IP: 192.168.2.0 / 255.255.255.0
* eth1: 192.168.2.1
* Password di root: secret
* Password Administrator del dominio: secret
* Password admin di LDAP: secret

Questi parametri vanno ovviamente adattati alle vostre esigenze.

Configurazioni preliminari

Al fine di non incappare in errori e al fine di velocizzare la ricerca dei nomi e ip è necessario installare e configurare bind9. Per poter assegnare gli indirizzi IP ai client di una rete è necessario configurare il DHCP server. Ricordo che si deve impostare l'interfaccia eth1 con ip statico 192.168.2.1 altrimenti il dhcp server non funzionerà. Per chi ha Ubuntu si deve prima disinstallare apparmor, questo servizio è una vera scocciatura ed inutile per un server:

#apt-get purge apparmor 

Configurazione DHCP

Un server DHCP può fornire anche altre proprietà di configurazione come:

  • Nome dell'host
  • Nome del dominio
  • Gateway predefinito
  • Server NTP (Network Time Protocol)
  • Server di stampa

Il vantaggio di utilizzare DHCP è che i cambiamenti apportati alla rete, per esempio una modifica dell'indirizzo del server DNS, devono essere apportati solamente al server DHCP, mentre tutti gli host della rete vengono riconfigurati quando i client DHCP interrogano il server DHCP. Come ulteriore vantaggio, risulta anche molto semplice integrare nuovi computer nella rete, senza la necessità di controllare la disponibilità di un indirizzo IP. I conflitti nell'allocazione degli indirizzi IP sono quindi notevolmente ridotti.

Installare il DHCP server:

#apt-get install dhcp3-server 

Per abbreviare non spiegherò i parametri configurati, ma andrò direttamente alla configurazione di esempio. La configurazione contempla un DHCP server dinamico.

#vim /etc/dhcp3/dhcpd.conf

editare come esempio:

include "/etc/dhcp3/rndc.key";

server-identifier	sole;
ddns-updates		on;
ddns-update-style	interim;
ddns-domainname		"dominio.local";
ddns-rev-domainname	"in-addr.arpa";
ignore			client-updates;

option domain-name "dominio.local";
option domain-name-servers 192.168.2.1;
option netbios-name-servers 192.168.2.1;
option netbios-node-type 8;
option ntp-servers  192.168.2.1;      
option ip-forwarding off;


default-lease-time	2592000;
max-lease-time		3092000;
authoritative;


subnet 192.168.2.0 netmask 255.255.255.0 {
	range 192.168.2.10 192.168.2.255;
	option routers 192.168.2.1;
	option broadcast-address 192.168.2.255;
	allow unknown-clients;
        allow known-clients;
	
	zone 2.168.192.in-addr.arpa. {
	primary 192.168.2.1;
	key "rndc-key";
	}

	zone dominio.local. {
	primary 192.168.2.1;
	key "rndc-key";
	}
}

Riavviamo: /etc/init.d/dhcp3-server restart

La configurazione sopra descritta è un server dhcp dinamico, il quale aggiorna il DNS automaticamente. Come potete notare è stato aggiunta una stringa di path /etc/dhcp3/rndc.key, questa è la chiave creata in sede di configurazione bind ed è stata copiata nella cartella del dhcp. Non descrivo altro sul dhcp e rimando a guide più dettagliate come questa: [1]

Configurazione DNS

Il DNS (Domain Name Service) è un servizio Internet che mappa gli indirizzi IP e i nomi di dominio univoci (FQDN) tra di loro facendo in modo di non dover ricordare gli indirizzi IP. I computer che eseguono DNS sono chiamati server dei nomi. Ubuntu è dotato di BIND (Berkley Internet Naming Daemon), il più diffuso programma usato per mantenere un server dei nomi su Linux. Ci sono diversi metodi per configurare BIND9. Alcune delle configurazioni più comuni consistono in un server dei nomi cache, un server primario e un server secondario.

   * Quando configurato come un server dei nomi cache, BIND9 troverà la risposta alle interrogazioni sui nomi e la archivierà.
   * Come server primario, BIND9 legge i dati per una zona da un file ed è autoritativo per quella zona.
   * Nella configurazione come server secondario, BIN9 ottiene i dati della zona da un altro server dei nomi per quella zona.

Installazione:

# apt-get install bind9 dnsutils

La configurazione che descriverò è basata su di un server primario che è autoritativo per quella zona. Descriverò solo la zona che ci servirà per risolvere i nomi dei client perciò non descriverò la zona localhost (che dovrebbe essere configurata di default).

Bind9 divide i files named.conf in tre configurazioni, rispettivamente named.conf.local, named.conf.options, named.conf.default-zones.

Descriverò tutti e tre precisando però che tutte le configurazioni devono essere richiamate da named.conf.

/etc/bind/named.conf.options

options {
	directory "/var/cache/bind";
        allow-transfer {
               127.0.0.1;
               192.168.2.0/24;
        };
        allow-query {
               127.0.0.1;
               192.168.2.0/24;
        };
	forwarders {
		83.103.25.250;
		62.101.93.101;
	};
        auth-nxdomain no;    # conform to RFC1035
	listen-on { any; };
	listen-on-v6 { any; };
};

/etc/bind/named.conf.local

logging {
    channel query.log {      
        file "/var/log/query.log"; 
        severity debug 3; 
    }; 
    category queries { query.log; }; 
};

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

include "/etc/bind/rndc.key";

zone "dominio.local" {
  type master;
  file "/etc/bind/db.dominio.local";
  allow-transfer { 127.0.0.1; 192.168.2.0/24; };
  allow-update { key "rndc-key"; };
  notify yes;
};

zone "2.168.192.in-addr.arpa" {
  type master;
  file "/etc/bind/db.192.168.2";
  allow-transfer { 127.0.0.1; 192.168.2.0/24; }; 
  allow-update { key "rndc-key"; };
  notify yes; 
};

Ora ci resta da configurare le zone: /etc/bind/db.dominio.local

$ORIGIN .
$TTL 604800
dominio.local	 SOA	server.dominio.local. root.localhost. (
				2010092446 ; serial
				604800     ; refresh (1 week)
				86400      ; retry (1 day)
				2419200    ; expire (4 weeks)
				604800 )    ; minimum (1 week)
;
@		 NS	server.dominio.local.
$ORIGIN dominio.local.
_samba_pdc_domain	 TXT	"DOMINIO"
_samba_pdc_ip_address	 TXT	"192.168.2.1"
_ldap_dc                TXT  "dc=dominio,dc=local"
_ldap_tcp		 SRV	0 0 389 server.dominio.local.
server			 A	192.168.2.1
pc1			 A	192.168.2.179
pc2			 A	192.168.2.73
pc3			 A	192.168.2.95
pc4   		         A	192.168.2.173

Notate che il serial ha il seguente formato (aaaammggss): deve essere cambiato ogni volta che si fanno cambiamenti alla configurazione. (ss=seriale, che avanza di uno ogni volta che si cambia la configurazione, tuttavia prima di cambiarlo si deve prima cambiare la data e se nello stesso giorno non si fanno altri cambiamenti allora rimane inalterato). pc1,pc2,... sono i clients presenti sulla rete e per ogni di esso si deve aggiungere l'IP corrispondente assegnato dal dhcp, che dovrebbe però aggiornarlo automaticamnte essendo dinamico.

Ora vediamo il reverse zone: /etc/bind/db.192.168.2

$ORIGIN .
$TTL 604800
2.168.192.in-addr.arpa	 SOA	server.dominio.local. root.localhost. (
				2010092446 ; serial
				604800     ; refresh (1 week)
				86400      ; retry (1 day)
				2419200    ; expire (4 weeks)
				604800 )    ; minimum (1 week)
;
@			NS	server.dominio.local.
$ORIGIN 2.168.192.in-addr.arpa.
1			PTR	server.dominio.local.
179			PTR	pc1.dominio.local.
73			PTR	pc2.dominio.local.
95			PTR	pc3.dominio.local.
173			PTR	pc4.dominio.local.

Ora configuriamo la chiave: /etc/bind/rndc.key

key "rndc-key" {
	algorithm hmac-md5;
	secret "b/E3LQuAiHs926ucqAP7Mg==";
};

"rndc-key" è il nome della chiave che ritroviamo anche nelle varie zone del file named.conf e nel dhcpd.conf. la chiave è creata con un determinato algoritmo che in questo caso è l'hash md5. Il comando per creare la chiave è:

# dnssec-keygen -a HMAC-MD5 -b 128 -n USER rndc-key

Copiare la chiave generata nel file /etc/bind/rndc.key, se il file non c'è bisogna crearlo. Un esempio di chiave generata è:

rndc-key. IN KEY 0 3 157 '''pfZ3xnS348/f5YRznSxWAg=='''

Quello che inizia per pfZ........ è la chiave.

Impostare i permessi:

chown -R root:bind /etc/bind
chmod -R 664 /etc/bind
chown root:bind /etc/bind/*
chmod 664 /etc/bind/* 

Configuriamo il resolv.conf: /etc/resolv.conf

nameserver 127.0.0.1
nameserver 192.168.2.1
domain dominio.local
search dominio.local

Impostare il blocco scrittura automatica del resolv.conf, altrimenti verrà riscritto:

# chattr +i /etc/resolv.conf

Per sbloccare la scrittura (nel caso voleste editarlo):

# chattr -i /etc/resolv.conf

Riavviamo il tutto: /etc/init.d/bind9 restart

testare il funzionamento:

# nslookup
# < server
Dovrebbe restituirvi l'indirizzo ip e la zona.
#< pc1
Dovrebbe restituirvi indirizzo ip e zone
# < exit
Uscita

LDAP Server

Installazione del server LDAP

Il server LDAP è essenzialmente un database gerarchico che viene utilizzato per la memorizzazione dei dati degli utenti, dei computer del dominio e di tutto quanto si desideri gestire tramite una base dati condivisibile via rete tra più sistemi.
Si considera che il server in questione venga utilizzato all'interno di una rete aziendale altamente affidabile e non verranno, pertanto, trattati gli aspetti relativi alla crittografia delle comunicazioni. Questa scelta riduce la sicurezza, pertanto si consiglia di approfondire l'argomento. Se si è interessati ad un'implementazione sicura del protocollo LDAP si veda ad esempio la guida Samba, OpenLDAP, Kerberos: creare un controller di dominio sicuro con Debian Lenny, che è basata sulla guida che state leggendo, ma che introduce e analizza una serie di aspetti legati alla trasmissione e all'archiviazione sicura delle informazioni.
Per utilizzare il server LDAP occorre installare il pacchetto slapd che costituisce un'implementazione di server LDAP per Linux e il pacchetto ldap-utils, un insieme di strumenti che ne permettono la gestione.

# apt-get install slapd ldap-utils samba-doc

Si presume che l'utente operi con l'account root per eseguire le operazioni di seguito descritte. Durante l'installazione verranno richieste alcune informazioni necessarie a configurare il server LDAP. In particolare verrà richiesto il nome del dominio che può essere un dominio interno completamente inventato (es. miodominio.tld) o un dominio internet valido. La scelta è legata a politiche organizzative aziendali e tecniche che richiederebbero una trattazione approfondita e che esula da questo HOWTO.
Nei file riportati si considera che il dominio specificato è dominio.local, un dominio interno non valido per Internet. In seguito verrà richiesta la password per l'utente amministratore. Scegliete una password particolarmente sicura, in quanto tramite essa si potrà avere accesso completo alla gestione degli utenti del vostro dominio e, pertanto, accedere a qualsiasi sistema presente sulla vostra rete. Questa password, inoltre, verrà utilizzata anche in seguito in alcuni file di configurazione, pertanto è bene ricordarsela.
Come nome dell'organizzazione mettete una descrizione della vostra organizzazione: Rete LAN di Dominio.
Per tutte le altre opzioni possono essere confermate le impostazioni di default.
Per andare più in profondità nella configurazione del server LDAP è consigliabile, subito dopo l'installazione, lanciare il comando:

# dpkg-reconfigure slapd

Verrà eseguita la riconfigurazione di OpenLDAP, ma saranno poste più domande. Rispondete così:

  • Omettere la configurazione di OpenLDAP: no
  • Nome del dominio: dominio.local
  • Nome dell'organizzazione: DOMINIO
  • Password di admin: secret
  • Conferma password: secret
  • Cancellare il database quando si effettua il purge di slapd: no
  • Spostare il vecchio database: sì
  • Permettere LDAPv2: no

Configurazione del server LDAP

Passiamo ora alla configurazione del server LDAP.

Innanzitutto effettuiamo un backup di LDAP:

# slapcat > ~/slapd.ldif
o semplicemente
# cp -R /etc/ldap/slapd.d /etc/slapd.d.backup

Adesso dobbiamo recuperare gli schemi mancanti, che aggiungeremo poi alla configurazione di LDAP, e copiare in /etc/ldap/schema lo schema LDAP necessario per SAMBA.

# cp /usr/share/doc/samba-doc/examples/LDAP/samba.schema.gz /etc/ldap/schema/
# gzip -d /etc/ldap/schema/samba.schema.gz
# mkdir /tmp/ldif_output

Creiamo il file schema_convert.conf ed editatelo:

#touch /tmp/schema_convert.conf
# vim /tmp/schema_convert.conf

editate così:

''include /etc/ldap/schema/core.schema
include /etc/ldap/schema/collective.schema
include /etc/ldap/schema/corba.schema
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/duaconf.schema
include /etc/ldap/schema/dyngroup.schema
include /etc/ldap/schema/inetorgperson.schema
include /etc/ldap/schema/java.schema
include /etc/ldap/schema/misc.schema
include /etc/ldap/schema/nis.schema
include /etc/ldap/schema/openldap.schema
include /etc/ldap/schema/ppolicy.schema
include /etc/ldap/schema/samba.schema''

salvate

# slapcat -f schema_convert.conf -F /tmp/ldif_output -n0 -s "cn={12}samba,cn=schema,cn=config" > /tmp/samba.ldif
# vim /tmp/samba.ldif

modificate il file come segue:

dn: cn=samba,cn=schema,cn=config
...
cn: samba

rimuovere le stringhe a fondo pagina:

structuralObjectClass: olcSchemaConfig
entryUUID: b53b75ca-083f-102d-9fff-2f64fd123c95
creatorsName: cn=config
createTimestamp: 20080827045234Z
entryCSN: 20080827045234.341425Z#000000#000#000000
modifiersName: cn=config
modifyTimestamp: 20080827045234Z

Salvate tutto e copiare in /etc/ldap/schema:

#cp /tmp/samba.ldif /etc/ldap/schema

Quindi generate l'hash MD5 della password di root di LDAP:

# slappasswd -s secret -h {MD5}

e prendete nota del risultato della password in md5.

La versione utilizzata di OpenLdap ha come file di configurazione la cartella slapd.d ubicata in /etc/ldap/slapd.d ed è stato quindi soppresso il precedente slapd.conf. La differenza è nella configurazione e nella funzionalità degli stessi. Il primo file di configurazione era statico perciò richiedeva sempre lo stop del demone slapd. Il secondo è dinamico perciò va da sè che è molto più flessibile.

In questa guida verrà utilizzato slapd.d come di default, ma ricordo che in /etc/default/slapd si può impostare il vecchio database slapd.conf oppure si può convertire un vecchio database slapd.conf in slapd.d con il comando:

  1. slaptest -f /etc/ldap/slapd.conf -F /etc/ldap/slapd.d

Ora occorre aggiungere gli schemi che ci serviranno per la cnfigurazione:

ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/cosine.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/nis.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/inetorgperson.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/samba.ldif 

Creare il file module.ldif per aggiungere il modulo del backend e crearlo:

# touch /tmp/module.ldif
# vim /tmp/module.ldif

editarlo così:

dn: cn=module,cn=config
objectClass: olcModuleList
cn: module
olcModulepath: /usr/lib/ldap
olcModuleload: back_bdb.la

salvare e caricare il file:

ldapadd -Y EXTERNAL -H ldapi:/// -f /tmp/module.ldif

Creare il file backend.ldif ed editarlo:

# touch /tmp/backend.ldif
# vim /tmp/backend.ldif

editarlo così:

dn: olcDatabase=bdb
objectClass: olcDatabaseConfig
objectClass: olcBdbConfig
olcDatabase: bdb
olcDbDirectory: /var/lib/ldap
olcSuffix: dc=dominio,dc=local
olcAccess: {0}to attrs=userPassword,SambaLMPassword,SambaNTPassword,sambaPwdLastSet,sambaPwdMustChange,sambaPasswordHistory by dn="cn=admin,dc=dominio,dc=local" write by anonymous auth by self write by * none
olcAccess: {1}to attrs=shadowLastChange by self write by * read
olcAccess: {2}to dn.base="" by self write by * read
olcAccess: {3}to * by dn="cn=admin,dc=dominio,dc=local" write by * read
olcLastMod: TRUE
olcRootDN: cn=admin,dc=dominio,dc=local
olcDbCheckpoint: 512 30
olcDbConfig: {0}set_cachesize 0 2097152 0
olcDbConfig: {1}set_lk_max_objects 1500
olcDbConfig: {2}set_lk_max_locks 1500
olcDbConfig: {3}set_lk_max_lockers 1500
olcDbIndex: objectClass eq
olcDbIndex: uidNumber eq
olcDbIndex: cn pres,sub,eq
olcDbIndex: sn pres,sub,eq
olcDbIndex: gidNumber eq
olcDbIndex: uid pres,sub,eq
olcDbIndex: memberUid eq
olcDbIndex: uniqueMember eq
olcDbIndex: displayName pres,sub,eq
olcDbIndex: sambaSID eq
olcDbIndex: sambaPrimaryGroupSID eq
olcDbIndex: sambaDomainName eq
olcDbIndex: sambaSIDList eq
olcDbIndex: sambaGroupType eq
olcDbIndex: default sub

Infine aggiungere le informazioni per l'autenticazione e la criptazione della password degli utenti:

# vim /etc/ldap/slapd.d/cn=config/olcDatabase={1}bdb.ldif

e aggiungere:

olcRootPW: {MD5}..--..\\..//..::
olcPasswordHash: {MD5}

Editiamo cn=config.ldif così:

olcLogLevel: 1 2 8 64 128 256 512
olcAuthzPolicy: none
olcAuthzRegexp: uid=(.*),cn=.*,cn=auth ldap:///dc=milanoaccademia,dc=lan??sub?(uid=$1)

Eliminiamo il contenuto della cartella /var/lib/ldap:

## rm -rf /var/lib/ldap/*

Riavviamo il demone slapd:

# /etc/init.d/slapd restart

Installazione e Configurazione dell'autenticazione LDAP

Per prima cosa installeremo il pacchetto libnss-ldap, con il classico comando:

# apt-get install libnss-ldap libpam-ldap

Rispondere alle domande di autoconfigurazione:

* Server LDAP: 127.0.0.1
* Distinguished name (DN): dc=dominio,dc=local
* LDAP version: 3
* Make local root Database admin: sí 
* Si richiede utente per database LDAP: no
* LDAP account for root cn=admin,dc=dominio,dc=local 
* LDAP root password: secret
* Local crypt to use when changing passwords: md5

Se sbagliate a configurare rilanciate la schermata con:

# dpkg-reconfigure ldap-auth-config

Assicuratevi che il file ldap.secret, dal quale traspare la password in chiaro, sia leggibile e scrivibile solo da root. Non impostatela criptata perchè altrimenti non vi autentica. Vi assicuro che se vi accertate dei permessi la password non trasparirà fuori.

Editate il file ldap.conf (le prime tre voci dovrebbero essere già editate correttamente mentre le altre voci devono essere decommentate ed editate:

host 127.0.0.1
base dc=dominio,dc=local
ldap_version 3
scope sub
bind_policy soft
pam_login_attribute uid
pam_member_attribute gid
pam_password exop
nss_base_passwd dc=dominio,dc=local?sub
nss_base_shadow dc=dominio,dc=local?sub
nss_base_group ou=groups,dc=dominio,dc=local?one

Lanciate i seguenti comandi di autoconfigurazione:

# pam-auth-update (Dal menù pam-auth-update, scegliere LDAP e unix, inoltre qualsiasi altro metodo di autenticazione necessario.)

# auth-client-config -t nss -p lac_ldap (configura nsswitch.conf all'uso di ldap)

     * -t: modifica solamente /etc/nsswitch.conf.
     
     * -p: nome del profilo da abilitare, disabilitare, ecc...

     * lac_ldap: il profilo auth-client-config parte del pacchetto ldap-auth-config.

Verificare il contenuto di /etc/nsswitch.conf e controllare le seguenti voci se corrispondono:

passwd: files ldap
group: files ldap
shadow: files ldap

A causa di un bug documentato (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=375077) e a cui il team di sviluppo di Debian ha fornito una soluzione parziale (è stato eliminato il problema, ma non i messaggi d'errore generati al boot) è possibile che al reboot compaiano messaggi di errore simili ai seguenti:

...
udevd[1350]: nss_ldap: could not connect to any LDAP server as cn=admin,dc=home,dc=tld - Can't contact LDAP server
udevd[1350]: nss_ldap: failed to bind to LDAP server ldap://127.0.0.1: Can't contact LDAP server
udevd[1350]: nss_ldap: could not search LDAP server - Server is unavailable
udevd[1350]: lookup_user: error resolving user 'tss': Illegal seek 
...

Una possibile via per eludere il problema è quella di aggiungere a mano gli utenti di sistema mancanti:

# addgroup --system tss
# addgroup --system kvm
# addgroup --system rdma
# addgroup --system fuse
# addgroup --system scanner
# addgroup --system nvram
# adduser --system tss

TLS e SSL

Introduzione

Transport Layer Security (TLS) e il suo predecessore Secure Sockets Layer (SSL) sono dei protocolli crittografici che permettono una comunicazione sicura e una integrità dei dati su reti TCP/IP come, ad esempio, internet. TLS e SSL cifrano la comunicazione dalla sorgente alla destinazione (end-to-end) sul livello di trasporto. Il protocollo TLS consente alle applicazioni client/server di comunicare attraverso una rete in modo tale da prevenire il 'tampering' (manomissione) dei dati, la falsificazione e l'intercettazione. Nell'utilizzo tipico di un browser da parte di utente finale, l'autenticazione TLS è unilaterale: solo il server è autenticato (il client conosce l'identità del server), ma non vice-versa (il client rimane anonimo e non autenticato). L'autenticazione del server è molto utile per il software di navigazione e per l'utente. Il browser valida il certificato del server controllando la firma digitale dei certificati del server controllando che questa sia valida e riconosciuta da una certificate authority conosciuta utilizzando una cifratura a chiave pubblica. Dopo questa autenticazione il browser indica una connessione sicura mostrando solitamente un lucchetto in un'icona in basso a destra. Questa autenticazione, però, non è sufficiente per garantire che il sito con cui ci si è collegati sia quello richiesto. Per esserne sicuri è necessario analizzare il contenuto del certificato rilasciato e controllarne la catena di certificazione. I siti che intendono ingannare l'utente non possono utilizzare un certificato del sito che vogliono impersonare perché non hanno la possibilità di cifrare in modo valido il certificato, che include l'indirizzo, in modo tale che risulti valido alla destinazione. Solo le CA possono generare certificati validi con un'URL incorporata in modo che il confronto fra l'URL apparente e quella contenuta nel certificato possa fornire un metodo certo per l'identificazione del sito. Molto spesso questo meccanismo non è noto agli utenti di internet ed è causa di varie frodi dovute, però, ad un incorretto utilizzo del browser non ad una debolezza del protocollo TLS. Ora vedremo come configuare ldap e samba affinchè usino l'autenticazione TLS unilaterale.

Configurazione

Per prima cosa procediamo all'installazione di gnutls-bin:

# apt-get install gnutls-bin
Creazione Certificato

Successivamente bisognerà ottenere un certificato usando l'utility certtoll:

  • Creiamo una chiave privata per Certificate Authority (CA):
# sh -c "certtool --generate-privkey > /etc/ssl/private/cakey.pem"
  • Creare il file /etc/ssl/ca.info, per autofirmare il CA certificate, con il seguente contenuto:
cn = server.dominio.local
ca
cert_signing_key
  • Ora creare il CA certificate autofirmato:
# certtool --generate-self-signed --load-privkey /etc/ssl/private/cakey.pem --template  /etc/ssl/ca.info 
--outfile /etc/ssl/certs/cacert.pem
  • Generare una chiave private per il server:
# sh -c "certtool --generate-privkey > /etc/ssl/private/server_slapd_key.pem"
  • Per firmare il certificato del server con il CA certificate, creare il file /etc/ssl/server.info con il contenuto:
organization = Server Dominio
cn = server.dominio.local
tls_www_server
encryption_key
signing_key
  • Ora creare il certificato per il server:
# certtool --generate-certificate --load-privkey /etc/ssl/private/server_slapd_key.pem  --load-ca-certificate 
/etc/ssl/certs/cacert.pem --load-ca-privkey /etc/ssl/private/cakey.pem  --template /etc/ssl/server.info 
--outfile /etc/ssl/certs/server_slapd_cert.pem
Modifiche di LDAP

Ora dobbiamo modificare il file cn=config.ldif di slapd.d affinchè usi il certificato: Creare il file /etc/ldap/tls.ldif:

dn: cn=config
add: olcTLSCACertificateFile
olcTLSCACertificateFile: /etc/ssl/certs/cacert.pem
-
add: olcTLSCertificateFile
olcTLSCertificateFile: /etc/ssl/certs/server_slapd_cert.pem
-
add: olcTLSCertificateKeyFile
olcTLSCertificateKeyFile: /etc/ssl/private/server_slapd_key.pem
>/pre>
Inseriamo le informazioni con il seguente comando:
<pre>
# ldapmodify -Y EXTERNAL -H ldapi:/// -f /etc/ldap/tls.ldif
Aprire il file /etc/default/slapd e togliere il commento dall'opzione SLAPD_SERVICES:
<pre>
SLAPD_SERVICES="ldap:/// ldapi:/// ldaps:///"

Garantire accesso al certificato all'utente openldap:

# adduser openldap ssl-cert
# chgrp ssl-cert /etc/ssl/private
# chgrp ssl-cert /etc/ssl/private/server_slapd_key.pem
# chmod 750 /etc/ssl/private/
# chmod 640 /etc/ssl/private/server_slapd_key.pem

Modificare /etc/ldap.conf:

uri ldpas://127.0.0.1/
ssl start_tls
ssl on
tls_checkpeer yes
tls_cacertfile /etc/ssl/certs/cacert.pem
tls_cacertdir /etc/ssl/certs
tls_cert /etc/ssl/certs/server_slapd_cert.pem
tls_key /etc/ssl/private/server_slapd_key.pem
Configurazione Samba

Modificare la seguente voce di smb.conf:

....
ldap ssl = start tls
....

In fine, riavviare slapd:

# /etc/init.d/slapd restart

Samba PDC con backend LDAP

Installazioni e configurazioni iniziali

L'installazione di Samba va effettuata in questo momento perchè insieme ai pacchetti stessi di Samba saranno installate anche alcune utility che adopereremo nel paragrafo successivo.

# apt-get install samba smbclient smbfs cupsys cupsys-bsd

E' necessario creare le cartelle netlogon, profiles e creare lo script logon.bat.

# mkdir -p /home/samba/netlogon
# chown -R root:root /home/samba/netlogon
# chmod -R 755 /home/samba/netlogon
# mkdir -p /home/samba/profiles
# chown root:root /home/samba/profiles
# chmod 755 /home/samba/profiles 

Creiamo il file logon.bat da mettere in netlogon: Tale script dovrà esser scritto in modalità dos, per far questo sfrutteremo il tool unix2dos contenuto nel pacchetto tofrodos.

# apt-get install tofrodos

creiamo lo script con l'editor che preferiamo

# vim /home/samba/netlogon/logon.bat

syncronizziamo gli orologi del client windows con il nostro server e mappiamo una condivisione di rete scrivendo nel file

net time \\SERVER /set /yes
net use H: /home 

infine

# unix2dos /home/samba/netlogon/logon.bat

Allo script si possono aggiungere operazioni come il montaggio di unità di rete o altre condivisioni. Tenete conto che con queste impostazioni viene già creata un'unità di rete collegata alla home dell'utente linux.

Per ogni utente deve essere creata una cartella profile:

# mkdir -p /home/samba/profiles/utente
# mkdir -p /home/samba/profiles/utente/{Desktop|Documenti/Immagini|Impostazioni locali/Dati Applicazioni|
Impostazioni locali/Cronologia|Preferiti|Cookies|Recent|Risorse di stampa}
# chown -R utente:"Domain Users" /home/samba/profiles/utente
# chmod -R 700 /home/samba/profiles/utente

E' necessario, per avere un corretto roaming profile, creare nel profilo comune dell'utente le cartelle da redirigere al server con i diritti di scrittura all'utente. Ho creato uno script ad hoc che fa tutto ciò e vi rimando al paragrafo 11.

Nota per il roaming profile:

Per poter ottenere un valido roaming profile con client windows è necessario copiare la cartella "Default User", 
che si trova in C:\Documents and Settings, nella cartella /home/samba/netlogon. Prima di copiarla bisogna editare 
il file NTUSER.dat dal registro regedit. Seguire questo procedimento:
1 . Start>Esegui>regedit>(posizionarsi su)HKEY_LOCAL_MACHINE
2. (andare su)file>carica hive>C:\Documents and Settings\Default User\NTUSER.dat>apri>(digitare nome)Default
3. (entrare in)HKEY_LOCAL_MACHINE>Default>Software>Microsoft>Windows>CurrentVersion>Explorer>User Shell Folder
4. cambiare i Dati, da %USERPROFILE% a %LOGONSERVER%\profiles\%USERNAME% dei Nomi: Desktop;Favorites;History;
   Local AppData; Local Settings;My Pictures;Personal; PrintHood;Recent (a scelta anche Cookies e Cache)
   es. da %USERPROFILE%\Desktop a %LOGONSERVER%\profiles\%USERNAME%\Desktop (così per tutti i nomi)
5. (posizionarsi su) Default
6. (andare su) file>scarica hive
7. copiare su /home/samba/netlogon la cartella "Default User" così modificata.

Configurazione di smb.conf

Ora vedremo come configurare Samba vero e proprio per essere un Primary Domain Controller con backend LDAP, affinchè si appoggi a questo per la gestione degli utenti, gruppi, ecc... Copiare il file smb.conf per avere un backup:

# cp /etc/samba/smb.conf /etc/samba/smb.conf.original

Editare il file smb.conf
# vim /etc/samba/smb.conf

Configurarlo così:

#======================= Global Settings =======================

[global]

## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = DOMINIO

# server string is the equivalent of the NT Description field
 netbios name = SERVER   
 server string = Server dominio 
# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable its WINS Server
   wins support = yes

# WINS Server - Tells the NMBD components of Samba to be a WINS Client
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
;   wins server = w.x.y.z

# This will prevent nmbd to search for NetBIOS names through DNS.
   dns proxy = no

# What naming service and in what order should we use to resolve host names
# to IP addresses
   name resolve order = wins lmhosts host bcast

#### Networking ####

# The specific set of interfaces / networks to bind to
# This can be either the interface name or an IP address/netmask;
# interface names are normally preferred
interfaces = eth1, lo
;   interfaces = 127.0.0.0/8 eth0

# Only bind to the named interfaces and/or networks; you must use the
# 'interfaces' option above to use this.
# It is recommended that you enable this feature if your Samba machine is
# not protected by a firewall or is a firewall itself.  However, this
# option cannot handle dynamic or non-broadcast interfaces correctly.
   bind interfaces only = yes



#### Debugging/Accounting ####

# This tells Samba to use a separate log file for each machine
# that connects
   log file = /var/log/samba/%U.%m.log
   log level = 0 passdb:6 auth:10 vfs:5 acls:3 msdfs:3 
# Cap the size of the individual log files (in KiB).
   max log size = 5000

# If you want Samba to only log through syslog then set the following
# parameter to 'yes'.
#   syslog only = no

# We want Samba to log a minimum amount of information to syslog. Everything
# should go to /var/log/samba/log.{smbd,nmbd} instead. If you want to log
# through syslog you should set the following parameter to something higher.
   syslog = 0

# Do something sensible when Samba crashes: mail the admin a backtrace
   panic action = /usr/share/samba/panic-action %d


####### Authentication #######

# "security = user" is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
# in the samba-doc package for details.
   security = user
   username map = /etc/samba/usermap
   case sensitive = no
# You may wish to use password encryption.  See the section on
# 'encrypt passwords' in the smb.conf(5) manpage before enabling.
   encrypt passwords = true
   enable privileges = yes
# If you are using encrypted passwords, Samba will need to know what
# password database type you are using.  
   passdb backend = ldapsam:ldap://127.0.0.1/
   ldap admin dn = cn=admin,dc=dominio,dc=local
   ldap suffix = dc=dominio,dc=local
   ldap user suffix = ou=users
   ldap group suffix = ou=groups
   ldap machine suffix = ou=computers
   ldap idmap suffix = ou=idmap
   ldap ssl = off
   ldap delete dn = no
   idmap backend = ldap:ldap://127.0.0.1
   obey pam restrictions = yes

# This boolean parameter controls whether Samba attempts to sync the Unix
# password with the SMB password when the encrypted SMB password in the
# passdb is changed.
ldap passwd sync = yes   
unix password sync = no

# For Unix password sync to work on a Debian GNU/Linux system, the following
# parameters must be set (thanks to Ian Kahan <<kahan@informatik.tu-muenchen.de> for
# sending the correct chat script for the passwd program in Debian Sarge).
   passwd program = /usr/sbin/smbldap-passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .

# This boolean controls whether PAM will be used for password changes
# when requested by an SMB client instead of the program listed in
# 'passwd program'. The default is 'no'.
   pam password change = yes

# This option controls how unsuccessful authentication attempts are mapped 
# to anonymous connections
   map to guest = bad user

########## Domains ###########

# Is this machine able to authenticate users. Both PDC and BDC
# must have this setting enabled. If you are the BDC you must
# change the 'domain master' setting to no
#
   domain logons = yes
   domain master = yes
   local master = yes 	
   preferred master = yes
   os level = 255
#
# The following setting only takes effect if 'domain logons' is set
# It specifies the location of the user's profile directory
# from the client point of view)
# The following required a [profiles] share to be setup on the
# samba server (see below)
   logon path = \\%N\profiles\%U
# Another common choice is storing the profile in the user's home directory
# (this is Samba's default)
#   logon path = \\%N\%U\profile

# The following setting only takes effect if 'domain logons' is set
# It specifies the location of a user's home directory (from the client
# point of view)
   logon drive = H:
   logon home = \\%N\%U

# The following setting only takes effect if 'domain logons' is set
# It specifies the script to run during logon. The script must be stored
# in the [netlogon] share
# NOTE: Must be store in 'DOS' file format convention
   logon script = logon.bat

# This allows Unix users to be created on the domain controller via the SAMR
# RPC pipe.  The example command creates a user account with a disabled Unix
# password; please adapt to your needs
 add user script = /usr/sbin/smbldap-useradd -a -m %u
 delete user script = /usr/sbin/smbldap-userdel %u
 add user to group script = /usr/sbin/smbldap-groupmod -m %u %g
 delete user from group script = /usr/sbin/smbldap-groupmod -x %u %g
 set primary group script = /usr/sbin/smbldap-usermod -g %g %u

# This allows machine accounts to be created on the domain controller via the 
# SAMR RPC pipe.  
# The following assumes a "machines" group exists on the system
 add machine script  = /usr/sbin/smbldap-useradd -t 0 -w %u

# This allows Unix groups to be created on the domain controller via the SAMR
# RPC pipe.  
 add group script = /usr/sbin/smbldap-groupadd -p %g
 delete group script = /usr/sbin/smbldap-groupdel %g
 ########## Printing ##########

# If you want to automatically load your printer list rather
# than setting them up individually then you'll need this
#   load printers = yes

# lpr(ng) printing. You may wish to override the location of the
# printcap file
;   printing = bsd
;   printcap name = /etc/printcap

# CUPS printing.  See also the cupsaddsmb(8) manpage in the
# cupsys-client package.
   printing = cups
 #  printcap name = cups

############ Misc ############

# Using the following line enables you to customise your configuration
# on a per machine basis. The %m gets replaced with the netbios name
# of the machine that is connecting
;   include = /home/samba/etc/smb.conf.%m

# Most people will find that this option gives better performance.
# See smb.conf(5) and /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/speed.html
# for details
# You may want to add the following on a Linux system:
#         SO_RCVBUF=8192 SO_SNDBUF=8192
 socket options = TCP_NODELAY

# The following parameter is useful only if you have the linpopup package
# installed. The samba maintainer and the linpopup maintainer are
# working to ease installation and configuration of linpopup and samba.
;   message command = /bin/sh -c '/usr/bin/linpopup "%f" "%m" %s; rm %s' &

# Domain Master specifies Samba to be the Domain Master Browser. If this
# machine will be configured as a BDC (a secondary logon server), you
# must set this to 'no'; otherwise, the default behavior is recommended.
#   domain master = auto

# Some defaults for winbind (make sure you're not using the ranges
# for something else.)
   idmap uid = 10000-20000
   idmap gid = 10000-20000
#   template shell = /bin/false
  
# The following was the default behaviour in sarge,
# but samba upstream reverted the default because it might induce
# performance issues in large organizations.
# See Debian bug #368251 for some of the consequences of *not*
# having this setting and smb.conf(5) for details.
#   winbind separator = + 
#   winbind enum groups = yes
#   winbind enum users = yes
#   winbind use default domain = yes
   time server = yes
   null passwords = no
# Setup usershare options to enable non-root users to share folders
# with the net usershare command.

# Maximum number of usershare. 0 (default) means that usershare is disabled.
;   usershare max shares = 100

# Allow users who've been granted usershare privileges to create
# public shares, not just authenticated ones
   usershare allow guests = yes

#======================= Share Definitions =======================

# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares.  This will share each
# user's home directory as \\server\username
[homes]
   comment = Home Directories
   browseable = no

# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
   read only = no

# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
 #  create mask = 0775

# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
;   directory mask = 0700

# By default, \\server\username shares can be connected to by anyone
# with access to the samba server.  Un-comment the following parameter
# to make sure that only "username" can connect to \\server\username
# This might need tweaking when using external authentication schemes
   valid users = %S
   vfs object = recycle
                recycle:repository = /home/%u/.cestino
                recycle:keeptree = Yes
                recycle:touch = Yes
                recycle:versions = Yes
                recycle:maxsize = 1048576
                recycle:exclude = ?~$*,~$*,*.tmp,index*.pl,index*.htm*,*.temp,*.TMP
                recycle:exclude_dir = /tmp,/temp,/cache
                recycle:noversions = *.docx,*.doc,*.xlsx,*.xls,*.ppt

# Un-comment the following and create the netlogon directory for Domain Logons
# (you need to configure Samba to act as a domain controller too.)
[netlogon]
   comment = Network Logon Service
   path = /home/samba/netlogon
   guest ok = yes
   read only = yes
   share modes = no

# Un-comment the following and create the profiles directory to store
# users profiles (see the "logon path" option above)
# (you need to configure Samba to act as a domain controller too.)
# The path below should be writable by all users so that their
# profile directory may be created the first time they log on
[profiles]
   comment = Users profiles
   path = /home/samba/profiles
   read only = no
   browseable = no
   profile acls = yes

[printers]
   comment = All Printers
   browseable = no
   path = /var/spool/samba
   printable = yes
   guest ok = no
   read only = yes
   create mask = 0700

# Windows clients look for this share name as a source of downloadable
# printer drivers
[print$]
   comment = Printer Drivers
   path = /var/lib/samba/printers
   browseable = yes
   read only = yes
   guest ok = no
# Uncomment to allow remote administration of Windows print drivers.
# You may need to replace 'lpadmin' with the name of the group your
# admin users are members of.
# Please note that you also need to set appropriate Unix permissions
# to the drivers directory for these users to have write rights in it
;   write list = root, @lpadmin

# A sample share for sharing your CD-ROM with others.
;[cdrom]
;   comment = Samba server's CD-ROM
;   read only = yes
;   locking = no
;   path = /cdrom
;   guest ok = yes

# The next two parameters show how to auto-mount a CD-ROM when the
#	cdrom share is accesed. For this to work /etc/fstab must contain
#	an entry like this:
#
#       /dev/scd0   /cdrom  iso9660 defaults,noauto,ro,user   0 0
#
# The CD-ROM gets unmounted automatically after the connection to the
#
# If you don't want to use auto-mounting/unmounting make sure the CD
#	is mounted on /cdrom
#
;   preexec = /bin/mount /cdrom
;   postexec = /bin/umount /cdrom

Una volta che abbiamo il file di configurazione pronto, possiamo verificare che non contenga errori con il comando:

# testparm

Creiamo e modifichiamo il file /etc/samba/usermap:

# touch /etc/samba/usermap

editarecosì:
root = root Administrator

Sistemiamo ora le ultime directory necessarie:

# rm -rf /etc/samba/*tdb
# rm -rf /var/lib/samba/*tdb
# rm -rf /var/lib/samba/*dat
# rm -f /var/log/samba/*

facciamo memorizzare a samba la password dell'utente ldap da usare per la connessione:

# smbpasswd -w password

e riavviamo il servizio:

# service smbd stop
# service nmbd stop
# service smbd start
# service nmbd start

Configurare i SMBLDAP TOOLS

I smbldap-tools sostituiscono i comandi standard di UNIX per la gestione di gruppi, utenti e password in modo da dialogare direttamente con il server LDAP e fornire un metodo per gestire in contemporanea gli account UNIX e SAMBA.

Installazione

Installare il pacchetto smbldap-tools

# apt-get install smbldap-tools

Configurazione

Modificare il file /etc/smbldap-tools/smbldap_bind.conf inserendo il DN dell'amministratore del server LDAP e la sua password. Il DN dell'amministratore è stato impostato automaticamente durante l'installazione del pacchetto Debian di slapd e corrisponde a "cn=admin,dc=dominio,dc=local", in cui il dominio dipende dalle configurazioni sopra riportate per il server LDAP. La password è quella richiesta in fase di installazione del server LDAP.

Editate /etc/smbldap-tools/smbldap_bind.conf:

############################
# Credential Configuration #
############################
# Notes: you can specify two differents configuration if you use a
# master ldap for writing access and a slave ldap server for reading access
# By default, we will use the same DN (so it will work for standard Samba
# release)
slaveDN="cn=admin,dc=dominio,dc=local"
slavePw="secret"
masterDN="cn=admin,dc=dominio,dc=local"
masterPw="secret"

Recuperate il SID di DOMINIO:

# net getlocalsid DOMINIO
DOMINIO
SID=":::::::::::::::::::::::::::::::::::"

Il SID va poi trascritto in smbldap.conf

Il contenuto del file dovrebbe essere il seguente:
/etc/smbldap-tools/smbldap.conf:


##############################################################################
#
# General Configuration
#
##############################################################################

# Put your own SID. To obtain this number do: "net getlocalsid".
# If not defined, parameter is taking from "net getlocalsid" return
SID=":::::::::::::::::::::::::::::::::::"

# Domain name the Samba server is in charged.
# If not defined, parameter is taking from smb.conf configuration file
# Ex: sambaDomain="IDEALX-NT"
sambaDomain="DOMINIO"


##############################################################################
#
# LDAP Configuration
#
##############################################################################

# Notes: to use to dual ldap servers backend for Samba, you must patch
# Samba with the dual-head patch from IDEALX. If not using this patch
# just use the same server for slaveLDAP and masterLDAP.
# Those two servers declarations can also be used when you have 
# . one master LDAP server where all writing operations must be done
# . one slave LDAP server where all reading operations must be done
#   (typically a replication directory)

# Slave LDAP server
# Ex: slaveLDAP=127.0.0.1
# If not defined, parameter is set to "127.0.0.1"
slaveLDAP="127.0.0.1"

# Slave LDAP port
# If not defined, parameter is set to "389"
slavePort="389"

# Master LDAP server: needed for write operations
# Ex: masterLDAP=127.0.0.1
# If not defined, parameter is set to "127.0.0.1"
masterLDAP="127.0.0.1"

# Master LDAP port
# If not defined, parameter is set to "389"
masterPort="389"

# Use TLS for LDAP
# If set to 1, this option will use start_tls for connection
# (you should also used the port 389)
# If not defined, parameter is set to "1"
ldapTLS="0"

# How to verify the server's certificate (none, optional or require)
# see "man Net::LDAP" in start_tls section for more details
verify=""

# CA certificate
# see "man Net::LDAP" in start_tls section for more details
cafile=""

# certificate to use to connect to the ldap server
# see "man Net::LDAP" in start_tls section for more details
clientcert=""

# key certificate to use to connect to the ldap server
# see "man Net::LDAP" in start_tls section for more details
clientkey=""

# LDAP Suffix
# Ex: suffix=dc=IDEALX,dc=ORG
suffix="dc=dominio,dc=local"

# Where are stored Users
# Ex: usersdn="ou=Users,dc=IDEALX,dc=ORG"
# Warning: if 'suffix' is not set here, you must set the full dn for usersdn
usersdn="ou=users,${suffix}"

# Where are stored Computers
# Ex: computersdn="ou=Computers,dc=IDEALX,dc=ORG"
# Warning: if 'suffix' is not set here, you must set the full dn for computersdn
computersdn="ou=computers,${suffix}"

# Where are stored Groups
# Ex: groupsdn="ou=Groups,dc=IDEALX,dc=ORG"
# Warning: if 'suffix' is not set here, you must set the full dn for groupsdn
groupsdn="ou=groups,${suffix}"

# Where are stored Idmap entries (used if samba is a domain member server)
# Ex: groupsdn="ou=Idmap,dc=IDEALX,dc=ORG"
# Warning: if 'suffix' is not set here, you must set the full dn for idmapdn
idmapdn="ou=idmap,${suffix}"

# Where to store next uidNumber and gidNumber available for new users and groups
# If not defined, entries are stored in sambaDomainName object.
# Ex: sambaUnixIdPooldn="sambaDomainName=${sambaDomain},${suffix}"
# Ex: sambaUnixIdPooldn="cn=NextFreeUnixId,${suffix}"
sambaUnixIdPooldn="sambaDomainName=${sambaDomain},${suffix}"

# Default scope Used
scope="sub"

# Unix password encryption (CRYPT, MD5, SMD5, SSHA, SHA, CLEARTEXT)
hash_encrypt="MD5"

# if hash_encrypt is set to CRYPT, you may set a salt format.
# default is "%s", but many systems will generate MD5 hashed
# passwords if you use "$1$%.8s". This parameter is optional!
crypt_salt_format="%s"

##############################################################################
# 
# Unix Accounts Configuration
# 
##############################################################################

# Login defs
# Default Login Shell
# Ex: userLoginShell="/bin/bash"
userLoginShell="/bin/false"

# Home directory
# Ex: userHome="/home/%U"
userHome="/home/%U"

# Default mode used for user homeDirectory
userHomeDirectoryMode="700"

# Gecos
userGecos="System User"

# Default User (POSIX and Samba) GID
defaultUserGid="513"

# Default Computer (Samba) GID
defaultComputerGid="515"

# Skel dir
skeletonDir="/etc/skel"

# Default password validation time (time in days) Comment the next line if
# you don't want password to be enable for defaultMaxPasswordAge days (be
# careful to the sambaPwdMustChange attribute's value)
#defaultMaxPasswordAge="180"

##############################################################################
#
# SAMBA Configuration
#
##############################################################################

# The UNC path to home drives location (%U username substitution)
# Just set it to a null string if you want to use the smb.conf 'logon home'
# directive and/or disable roaming profiles
# Ex: userSmbHome="\\PDC-SMB3\%U"
userSmbHome=""

# The UNC path to profiles locations (%U username substitution)
# Just set it to a null string if you want to use the smb.conf 'logon path'
# directive and/or disable roaming profiles
# Ex: userProfile="\\PDC-SMB3\profiles\%U"
userProfile=""

# The default Home Drive Letter mapping
# (will be automatically mapped at logon time if home directory exist)
# Ex: userHomeDrive="H:"
userHomeDrive="H:"

# The default user netlogon script name (%U username substitution)
# if not used, will be automatically username.cmd
# make sure script file is edited under dos
# Ex: userScript="startup.cmd" # make sure script file is edited under dos
userScript="logon.bat"

# Domain appended to the users "mail"-attribute
# when smbldap-useradd -M is used
# Ex: mailDomain="idealx.com"
mailDomain="milanoaccademia.lan"

##############################################################################
#
# SMBLDAP-TOOLS Configuration (default are ok for a RedHat)
#
##############################################################################

# Allows not to use smbpasswd (if with_smbpasswd == 0 in smbldap_conf.pm) but
# prefer Crypt::SmbHash library
with_smbpasswd="0"
smbpasswd="/usr/bin/smbpasswd"

# Allows not to use slappasswd (if with_slappasswd == 0 in smbldap_conf.pm)
# but prefer Crypt:: libraries
with_slappasswd="0"
slappasswd="/usr/sbin/slappasswd"

# comment out the following line to get rid of the default banner
# no_banner="1"

Da notare:

  • userLoginShell="/bin/false" ( In questo modo gli utenti non possono loggarsi in unix equindi neanche in ssh)
  • #defaultMaxPasswordAge="180" (se volete che la password scada decommentatela ed indicata la scadenza)
  • userSmbHome="" e userProfile="" (sono vuote perchè se le avete impostate già in samba non serve farlo due volte)


  ATTENZIONE
Se volete che l'utente si logghi su unix e ssh è necessario modificare la shell con il comando:

# smbldap-usermod -s /bin/bash utente
(sempre che sia già stato fatto il popolamento,come di seguito descritto, e sempre che l'utente sia già stato creato)


Assegnare i permessi

# chmod 644 /etc/smbldap-tools/smbldap.conf
# chmod 600 /etc/smbldap-tools/smbldap_bind.conf