OpenLDAP: Instalando e Configurando um servidor OpenLDAP

From Wiki
Revision as of 19:54, 5 February 2019 by Ebasso (talk | contribs)

Passos para Instalar e Configurar o OpenLDAP


Procedimento

Instalando

1) Instalando os Pacotes

yum update
yum install -y openldap-servers openldap-clients

systemctl enable slapd
systemctl start slapd

2) Definindo a senha

slappasswd -h {SSHA} -s <COLOQUE_A_SENHA>

Salve o resultado

3) Criar o arquivo db.ldif e adicionar o conteúdo

dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=company,dc=com

dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=ldapadm,dc=company,dc=com

dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootPW
olcRootPW: <RESULTADO DO PASSO 2>

Salve e feche o arquivo. Execute o comando

ldapmodify -Y EXTERNAL -H ldapi:/// -f db.ldif

4) Criar o arquivo monitor.ldif e adicionar o conteúdo

dn: olcDatabase={2}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external, cn=auth" read by dn.base="cn=ldapadm,#{ ldap_suffix }" read by * none

Salve e feche o arquivo. Execute o comando

ldapmodify -Y EXTERNAL -H ldapi:/// -f /home/vagrant/monitor.ldif

5) Configurar o DB_CONFIG

Executar o comando:

cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG

chown ldap:ldap /var/lib/ldap/*

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

Configurando o Base

6) Criar o arquivo base.ldif e adicionar o conteúdo

dn: dc=company,dc=com
dc: company
objectClass: top
objectClass: domain

dn: cn=ldapadm,#{ ldap_suffix }
objectClass: organizationalRole
cn: ldapadm
description: LDAP Manager

dn: ou=People,dc=company,dc=com
objectClass: organizationalUnit
ou: People

dn: ou=Group,dc=company,dc=com
objectClass: organizationalUnit
ou: Group

Salve e feche o arquivo. Execute o comando

ldapadd -x -w "<SENHA_DO_LDAPADM>" -D "cn=ldapadm,dc=company,dc=com" -f base.ldif

Adicionando usuários

7) Gerando a senha

slappasswd -h {SSHA} -s <SENHA>

Anotar o resultado

8) Criar o arquivo add_users.ldif e adicionar o conteúdo

dn: uid=ebasso,ou=People,#{ ldap_suffix }
objectClass: top
objectClass: account
objectClass: posixAccount
cn: Enio Basso
uid: ebasso
uidNumber: 10000
gidNumber: 10000
homeDirectory: /home/ebasso
userPassword: <RESULTADO DO PASSO 8>


Salve e feche o arquivo. Execute o comando

ldapadd -x -w "<SENHA_DO_LDAPADM>" -D "cn=ldapadm,dc=company,dc=com" -f add_users.ldif

Ver também