#!/bin/ksh 
#  ALTRAN_PROLOG_BEGIN_TAG
#  This is an automatically generated prolog.
#
#  Copyright (C) Altran ACT S.A.S. 2017,2018,2019,2021.  All rights reserved.
#
#  ALTRAN_PROLOG_END_TAG
#
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/usr/sbin/cluster/cspoc/utilities/cl_ldapcl_del.sh 1.1 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2010,2011 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
# @(#)  7d4c34b 43haes/usr/sbin/cluster/cspoc/utilities/cl_ldapcl_del.sh, 726, 2147A_aha726, Feb 05 2021 09:50 PM

. /usr/es/sbin/cluster/cspoc/cl_federatedsec_source
fsec_init
##MAIN START##

export PATH=$(/usr/es/sbin/cluster/utilities/cl_get_path all)

CLNT_KDB_PATH=$1
KDB_BIT=$2

#Running cl_rbac_permissions_conf to restore the
#file permissions and the ODMs group after disabling
#LDAP client on the node.

#Don't call following script when cl_ldapcl_del
#is called as part of exisiting LDAP server setup.

if [[ $LDAP_DEL_ACTION != "NO" ]];then
        cl_rbac_permissions_conf disable
fi

#echo "Unconfiguring LDAP client..."
ps -eo 'args'|grep secldapclntd|grep -vw grep > /dev/null
if [[ $? -eq 0 ]]
then
	/usr/sbin/mksecldap -c -U 
	/usr/sbin/lsitab "ldapclntd" && /usr/sbin/rmitab "ldapclntd" >/dev/null
fi

#echo "Removing SSL client keys..."
[[ $KDB_BIT -eq 0 ]] && [ -f $CLNT_KDB_PATH ] && /usr/bin/rm -r `echo "$(echo $CLNT_KDB_PATH |sed s/\.kdb//g)*"`

run_on_allnode "rm -rf $FSEC_LOG_DIR" || ret_fail "Removing log directory failed." $?

exit 0

##MAIN END##