OpenLDAP: Instalando e Configurando um servidor OpenLDAP: Difference between revisions

From Wiki
No edit summary
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
Passos para Instalar e Configurar o OpenLDAP
Passos para Instalar e Configurar o OpenLDAP.


Atualizado para a versão 2.6 do OpenLDAP


= Procedimento =
= Procedimento =
Line 21: Line 22:
3) Criar o arquivo db.ldif e adicionar o conteúdo
3) Criar o arquivo db.ldif e adicionar o conteúdo


  dn: olcDatabase={2}hdb,cn=config
  dn: olcDatabase={2}mdb,cn=config
  changetype: modify
  changetype: modify
  replace: olcSuffix
  replace: olcSuffix
  olcSuffix: '''dc=test,dc=net'''
  olcSuffix: '''dc=test,dc=net'''
   
   
  dn: olcDatabase={2}hdb,cn=config
  dn: olcDatabase={2}mdb,cn=config
  changetype: modify
  changetype: modify
  replace: olcRootDN
  replace: olcRootDN
  olcRootDN: cn=ldapadm,'''dc=test,dc=net'''
  olcRootDN: cn=ldapadm,'''dc=test,dc=net'''
   
   
  dn: olcDatabase={2}hdb,cn=config
  dn: olcDatabase={2}mdb,cn=config
  changetype: modify
  changetype: modify
  replace: olcRootPW
  replace: olcRootPW
Line 42: Line 43:
4) Criar o arquivo monitor.ldif e adicionar o conteúdo
4) Criar o arquivo monitor.ldif e adicionar o conteúdo


  dn: olcDatabase={2}monitor,cn=config
  dn: olcDatabase={1}monitor,cn=config
  changetype: modify
  changetype: modify
  replace: olcAccess
  replace: olcAccess
Line 55: Line 56:
Executar o comando:
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/cosine.ldif
  ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif
  ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif
Line 84: Line 81:
  objectClass: organizationalUnit
  objectClass: organizationalUnit
  ou: Group
  ou: Group
dn: ou=Partners,'''dc=test,dc=net'''
objectClass: organizationalUnit
ou: Partners


Salve e feche o arquivo. Execute o comando
Salve e feche o arquivo. Execute o comando
Line 108: Line 109:
  gidNumber: 10000
  gidNumber: 10000
  homeDirectory: /home/ebasso
  homeDirectory: /home/ebasso
userPassword: <RESULTADO DO PASSO 7>
dn: uid=partner01,ou=Partners,'''dc=test,dc=net'''
objectClass: top
objectClass: account
objectClass: posixAccount
cn: External Partner 01
uid: partner01
uidNumber: 10001
gidNumber: 10001
homeDirectory: /home/partner01
  userPassword: <RESULTADO DO PASSO 7>
  userPassword: <RESULTADO DO PASSO 7>



Latest revision as of 22:38, 22 November 2024

Passos para Instalar e Configurar o OpenLDAP.

Atualizado para a versão 2.6 do OpenLDAP

Procedimento

Instalando

1) Instalando os Pacotes

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

systemctl enable slapd
systemctl start slapd

2) Definindo a senha

slappasswd

Salve o resultado, que devemos utilizar <SENHA_ENCRIPTADA_LDAP_ADMIN>

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

dn: olcDatabase={2}mdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=test,dc=net

dn: olcDatabase={2}mdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=ldapadm,dc=test,dc=net

dn: olcDatabase={2}mdb,cn=config
changetype: modify
replace: olcRootPW
olcRootPW: <SENHA_ENCRIPTADA_LDAP_ADMIN>

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={1}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,dc=test,dc=net" read by * none

Salve e feche o arquivo. Execute o comando

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

5) Configurar o DB_CONFIG

Executar o comando:

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=test,dc=net
dc: test
objectClass: top
objectClass: domain

dn: cn=ldapadm,dc=test,dc=net
objectClass: organizationalRole
cn: ldapadm
description: LDAP Manager

dn: ou=People,dc=test,dc=net
objectClass: organizationalUnit
ou: People

dn: ou=Group,dc=test,dc=net
objectClass: organizationalUnit
ou: Group

dn: ou=Partners,dc=test,dc=net
objectClass: organizationalUnit
ou: Partners

Salve e feche o arquivo. Execute o comando

ldapadd -x -w "<SENHA_LDAP_ADMIN>" -D "cn=ldapadm,dc=test,dc=net" -f base.ldif

Adicionando usuários

7) Gerando a senha

slappasswd

Anotar o resultado

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

dn: uid=ebasso,ou=People,dc=test,dc=net
objectClass: top
objectClass: account
objectClass: posixAccount
cn: Enio Basso
uid: ebasso
uidNumber: 10000
gidNumber: 10000
homeDirectory: /home/ebasso
userPassword: <RESULTADO DO PASSO 7>

dn: uid=partner01,ou=Partners,dc=test,dc=net
objectClass: top
objectClass: account
objectClass: posixAccount
cn: External Partner 01
uid: partner01
uidNumber: 10001
gidNumber: 10001
homeDirectory: /home/partner01
userPassword: <RESULTADO DO PASSO 7>


Salve e feche o arquivo. Execute o comando

ldapadd -x -w "<SENHA_LDAP_ADMIN>" -D "cn=ldapadm,dc=test,dc=net" -f add_users.ldif


Exemplo: Usando o Apache Directory Studio para visualizar - foto ilustrativa

Ver também