How to configure Ldap Client in Solaris:
Configuration File:
/etc/ldap.conf
/etc/nsswitch.conf
/etc/hosts
/etc/resolv.conf
/etc/auto.master
What are the Service need to be start Configuring Ldap client and Automount
Service nscd restart
service autofs restart
Pls run This script and it will configure Ldap automatically
#/usr/bin/sh
echo "=============================================="
echo " LDAP CLIENT CONFIGURATION "
echo "=============================================="
echo -n "Enter your primary LDAP server ip address (default:x.x.x.x):"
#read primaryip
if ( test "primaryip"="")
then
primaryip="x.x.x.x"
fi
#Validating the primary ip address
echo $primaryip | egrep '^([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}$' >/dev/null 2>&1
while [[ $? != "0" ]]
do
echo "Invalid format : Please re enter the ip address."
read primaryip
echo $primaryip | egrep '^([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}$' >/dev/null 2>&1
done
#Pinging the primary ip address
echo "Pinging the primary LDAP server $primaryip"
ping -c3 $primaryip > /dev/null 2>&1
while [[ $? != "0" ]]
do
echo "Ping unsuccessful : Please re enter the ip address."
read primaryip
echo $primaryip | egrep '^([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}$' >/dev/null 2>&1
while [[ $? != "0" ]]
do
echo "Invalid format : Please re enter the ip address."
read primaryip
echo $primaryip | egrep '^([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}$' >/dev/null 2>&1
done
echo "Pinging the primary LDAP server $primaryip"
ping -c3 $primaryip > /dev/null 2>&1
done
# Getting the primary ldap server name
echo -n "Enter your primary LDAP server name (default:ldap1.itchoice.com):"
#read primaryservername
if ( test "primaryservername=""")
then
primaryservername="ldap1.itchoice.com"
fi
echo -n "Enter your secondary LDAP server ip address (default:x.x.x.x):"
#read secondaryip
if ( test "secondaryip"="")
then
secondaryip="x.x.x.x"
fi
#Validating the secondary ip address
echo $secondaryip | egrep '^([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}$' >/dev/null 2>&1
while [[ $? != "0" ]]
do
echo "Invalid format : Please re enter the ip address."
read secondaryip
echo $secondaryip | egrep '^([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}$' >/dev/null 2>&1
done
#Pinging the secondary ip address
echo "Pinging the secondary LDAP server $secondaryip"
ping -c3 $secondaryip > /dev/null 2>&1
while [[ $? != "0" ]]
do
echo "Ping unsuccessful : Please re enter the ip address."
read secondaryip
echo $secondaryip | egrep '^([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}$' >/dev/null 2>&1
while [[ $? != "0" ]]
do
echo "Invalid format : Please re enter the ip address."
read secondaryip
echo $secondaryip | egrep '^([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}$' >/dev/null 2>&1
done
echo "Pinging the secondary LDAP server $secondaryip"
ping -c3 $secondaryip > /dev/null 2>&1
done
# Getting the secondary ldap server name
echo -n "Enter your secondary LDAP server name (default:ldap2.itchoice.com):"
#read secondaryservername
if ( test "secondaryservername=""")
then
secondaryservername="ldap2.itchoice.com"
fi
if [ -f /etc/ldap.conf ];then
cp /etc/ldap.conf{,_bak}
cp /etc/openldap/ldap.conf{,_bak}
#Putting the values in /etc/hosts
cat /etc/hosts|grep -i $primaryip >/dev/null 2>&1
if [ $? != "0" ];then
echo "$primaryip $primaryservername" >> /etc/hosts
fi
cat /etc/hosts|grep -i $secondaryip >/dev/null 2>&1
if [ $? != "0" ];then
echo "$secondaryip $secondaryservername" >> /etc/hosts
fi
echo "#This is configuration file for Client" > /etc/ldap.conf
echo "#ITchoice Configuration" >> /etc/ldap.conf
echo "host $primaryip $secondaryip" >> /etc/ldap.conf
echo "base dc=itchoice,dc=com" >> /etc/ldap.conf
echo "binddn uid=proxyagent,ou=profile,dc=itchoice,dc=com" >> /etc/ldap.conf
echo "bindpw hello" >> /etc/ldap.conf
echo "scope sub" >> /etc/ldap.conf
echo "timelimit 30" >> /etc/ldap.conf
echo "ssl no" >> /etc/ldap.conf
echo "pam_password md5" >> /etc/ldap.conf
cp -p /etc/ldap.conf /etc/openldap/ldap.conf
#Setting automounter
cp /etc/auto.master{,_bak}
echo "#Automount Itchoice config" > /etc/auto.master
echo "/home ldap:$primaryservername:nisMapName=home,ou=automount,dc=itchoice,dc=com" >> /etc/auto.master
echo "/data/ ldap:$primaryservername:nisMapName=local,ou=automount,dc=itchoice,dc=com" >> /etc/auto.master
fi
chkconfig autofs on
echo "Starting the autofs service"
service autofs restart
if [ -f /etc/nsswitch.conf ];then
cp -f /etc/nsswitch.conf{,_bak}
cat /etc/nsswitch.conf|sed -e '/^passwd\|^shadow\|^group/d'>/etc/nsswitch.conf1
mv -f /etc/nsswitch.conf1 /etc/nsswitch.conf
echo >>/etc/nsswitch.conf
echo "passwd: files ldap">>/etc/nsswitch.conf
echo "shadow: files ldap">>/etc/nsswitch.conf
echo "group: files ldap">>/etc/nsswitch.conf
fi
service ypbind stop
chkconfig ypbind off
echo "LDAP configuration successful. Changed files are /etc/hosts, /etc/nsswitch.conf, /etc/ldap.conf, /etc/auto.master, /etc/openldap/ldap.conf"
service nscd restart
service autofs restart
No comments:
Post a Comment