Search This Blog

Saturday, 3 December 2016

pressed ldap configuration

How To Pressed LDAP Configuration in non-interactive mode ?

LDAP Server Configuration :

1. install the following packages using apt-get 

 apt-get install -y aptitude
 apt-get install -y expect
 apt-get install -y debconf-utils

2. install slapd in noninteractive mode 

aptitude update
aptitude install expect

VAR=$(expect -c '
spawn aptitude -y install slapd
expect "New password for the slapd \"root\" user:"
send "123\r"
expect "Repeat password for the slapd \"root\" user:"
send "123\r"
expect eof

echo "$VAR"

aptitude -y install slapd

3. Configure slapd from backend 

debconf-get-selections | grep "slapd" (Displays all parameters of "slapd")

echo slapd slapd/no_configuration boolean false | sudo debconf-set-selections
echo slapd slapd/domain string | sudo debconf-set-selections
echo slapd shared/organization string | sudo debconf-set-selections
echo slapd slapd slapd/password1 password 123 | sudo debconf-set-selections
echo slapd slapd slapd/password2 password 123 | sudo debconf-set-selections
echo slapd slapd slapd/internal/adminpw password 123 | sudo debconf-set-selections
echo slapd slapd slapd/internal/generated_adminpw password 123 | sudo debconf-set-selections
echo slapd slapd/backend select HDB | sudo debconf-set-selections
echo slapd slapd/purge_database boolean false | sudo debconf-set-selections
echo slapd slapd/move_old_database boolean true | sudo debconf-set-selections
echo slapd slapd/allow_ldap_v2 boolean false | sudo debconf-set-selections

4. Change in file Configurations 

sed -i 's/#BASE/BASE/g'  /etc/ldap/ldap.conf
sed -i 's/dc=example/dc=ldap/g' /etc/ldap/ldap.conf

sed -i '9d' /etc/ldap/ldap.conf
sed -i "9i URI     ldap://localhost" /etc/ldap/ldap.conf

LDAP Client Configuration :

1. install Dependency packages

sudo apt-get install -y debconf-utils
sudo apt-get install -y aptitude

2. install ldap-auth-client package in noninteractive mode 

sudo DEBIAN_FRONTEND=noninteractive aptitude install -y -q ldap-auth-client

3. Configure ldap-auth client package from backend

echo ldap-auth-config ldap-auth-config/ldapns/ldap-server string ldap:// | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/ldapns/base-dn string dc=ldap,dc=com | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/ldapns/ldap_version select 3 | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/dbrootlogin boolean true | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/dblogin boolean false | sudo debconf-set-selections
echo ldap-auth-config ldap-auth-config/rootbinddn string cn=admin,dc=ldap,dc=com  | sudo debconf-set-selections

4. make changes in configuration files 

- set the ldap server ip  in ldap.conf

sed -i 's/uri ldapi:\/\/\//uri ldap:\/\/\//g' /etc/ldap.conf

- set base dn in /etc/ldap.conf

sed -i 's/base dc=example,dc=net/base dc=ldap,dc=com/g' /etc/ldap.conf
sed -i 's/rootbinddn cn=manager,dc=example,dc=net/rootbinddn cn=admin,dc=ldap,dc=com/g' /etc/ldap.conf

- save password in /etc/ldap.secret file 
echo "123" >/etc/ldap.secret
sudo chmod 600 /etc/ldap.secret

No comments:

Post a Comment

Switch between multiple PHP version in Ubuntu

If you have two php versions (e.g. PHP7.2 and PHP 5.6 ) installed in your ubuntu system. Switch from PHP 5.6 to PHP 7.2 =====> Apac...