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

From Wiki
No edit summary
Line 24: Line 24:
  changetype: modify
  changetype: modify
  replace: olcSuffix
  replace: olcSuffix
  olcSuffix: '''dc=company,dc=com'''
  olcSuffix: '''dc=test,dc=net'''
   
   
  dn: olcDatabase={2}hdb,cn=config
  dn: olcDatabase={2}hdb,cn=config
  changetype: modify
  changetype: modify
  replace: olcRootDN
  replace: olcRootDN
  olcRootDN: cn=ldapadm,'''dc=company,dc=com'''
  olcRootDN: cn=ldapadm,'''dc=test,dc=net'''
   
   
  dn: olcDatabase={2}hdb,cn=config
  dn: olcDatabase={2}hdb,cn=config
Line 45: Line 45:
  changetype: modify
  changetype: modify
  replace: olcAccess
  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=company,dc=com'''" read by * none
  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
Salve e feche o arquivo. Execute o comando
Line 67: Line 67:
6) Criar o arquivo base.ldif e adicionar o conteúdo
6) Criar o arquivo base.ldif e adicionar o conteúdo


  dn: '''dc=company,dc=com'''
  dn: '''dc=test,dc=net'''
  dc: '''company'''
  dc: '''test'''
  objectClass: top
  objectClass: top
  objectClass: domain
  objectClass: domain
   
   
  dn: cn=ldapadm,'''dc=company,dc=com'''
  dn: cn=ldapadm,'''dc=test,dc=net'''
  objectClass: organizationalRole
  objectClass: organizationalRole
  cn: ldapadm
  cn: ldapadm
  description: LDAP Manager
  description: LDAP Manager
   
   
  dn: ou=People,'''dc=company,dc=com'''
  dn: ou=People,'''dc=test,dc=net'''
  objectClass: organizationalUnit
  objectClass: organizationalUnit
  ou: People
  ou: People
   
   
  dn: ou=Group,'''dc=company,dc=com'''
  dn: ou=Group,'''dc=test,dc=net'''
  objectClass: organizationalUnit
  objectClass: organizationalUnit
  ou: Group
  ou: Group
Line 87: Line 87:
Salve e feche o arquivo. Execute o comando
Salve e feche o arquivo. Execute o comando


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


== Adicionando usuários ==
== Adicionando usuários ==
Line 99: Line 99:
8) Criar o arquivo add_users.ldif e adicionar o conteúdo
8) Criar o arquivo add_users.ldif e adicionar o conteúdo


  dn: uid=ebasso,ou=People,'''dc=company,dc=com'''
  dn: uid=ebasso,ou=People,'''dc=test,dc=net'''
  objectClass: top
  objectClass: top
  objectClass: account
  objectClass: account
Line 113: Line 113:
Salve e feche o arquivo. Execute o comando
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
  ldapadd -x -w "'''<SENHA_DO_LDAPADM>'''" -D "cn=ldapadm,'''dc=test,dc=net'''" -f add_users.ldif





Revision as of 21:13, 5 September 2020

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

Salve o resultado, que devemos utilizar <SENHA_ENCRIPTADA_LDAP_ADMIN>

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

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

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

dn: olcDatabase={2}hdb,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={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,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:

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=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

Salve e feche o arquivo. Execute o comando

ldapadd -x -w "<SENHA_DO_LDAPADM>" -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>


Salve e feche o arquivo. Execute o comando

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


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

Ver também