3
source @datadir@/@package_name@/data/DSSharedLib
5
libpath_add "@ldapsdk_libdir@"
7
libpath_add "@nss_libdir@"
8
libpath_add "@libdir@/@package_name@/"
10
export LD_LIBRARY_PATH
11
SHLIB_PATH=$LD_LIBRARY_PATH
13
PATH=$PATH:@ldaptool_bindir@:@ldaptool_bindir@:/usr/bin:/usr/lib64/mozldap
17
echo "Usage: ldif2ldap [-Z serverID] [-D <rootdn>] -w <password> -f <file> [-P protocol] [-h]"
19
echo " -Z serverID - Server instance identifier"
20
echo " -D rootdn - Directory Manager DN"
21
echo " -w passwd - Directory Manager password"
22
echo " -f file - File containing LDAP entries to add to the server"
23
echo " -P protocol - STARTTLS, LDAPS, LDAPI, LDAP"
24
echo " -h - Display usage"
27
while getopts "Z:D:w:f:hP:" flag
34
f) args=$args"-f $OPTARG"
43
if [ "$input_file" == "" ]
49
initfile=$(get_init_file "@initconfigdir@" $servid)
53
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
54
echo "Available instances: $initfile"
60
process_dse $CONFIG_DIR $$
61
file="/tmp/DSSharedLib.$$"
62
port=$(grep -i 'nsslapd-port' $file | awk '{print $2}' )
63
host=$(grep -i 'nsslapd-localhost' $file | awk '{print $2}' )
64
security=$(grep -i 'nsslapd-security' $file | awk '{print $2}' )
65
secure_port=$(grep -i 'nsslapd-secureport' $file | awk '{print $2}' )
66
ldapi=$(grep -i 'nsslapd-ldapilisten' $file | awk '{print $2}' )
67
ldapiURL=$(grep -i 'nsslapd-ldapifilepath' $file | awk '{print $2}' )
68
certdir=$(grep -i 'nsslapd-certdir' $file | awk '{print $2}' )
69
autobind=$(grep -i 'nsslapd-ldapiautobind' $file | awk '{print $2}' )
70
if [ "$rootdn" == "" ]; then
71
value=$(grep -i 'nsslapd-rootdn' $file)
72
rootdn=`echo "$value" | sed -e 's/nsslapd-rootdn: //i'`
76
if [ "$ldapiURL" != "" ]; then
77
ldapiURL=`echo "$ldapiURL" | sed -e 's/\//%2f/g'`
78
ldapiURL="ldapi://"$ldapiURL
81
client_type=`ldapmodify -V 2>&1`;
82
echo "$client_type" | grep -q "OpenLDAP"
86
export LDAPTLS_CACERTDIR=$certdir
89
if [ -z $security ]; then
92
revised_protocol=$(check_protocol $protocol $security $ldapi $openldap)
93
if [ "$revised_protocol" != "$protocol" ]; then
94
echo Protocol $protocol requested, but this protocol is not supported
97
protocol=$revised_protocol
102
if [ "$security" == "on" ]; then
103
if [ "$protocol" == "STARTTLS" ] || [ "$protocol" == "" ]; then
104
if [ "$error" == "yes" ]; then
105
echo "Using the next most secure protocol(STARTTLS)"
107
if [ "$openldap" == "yes" ]; then
108
ldapmodify -x -ZZ -p $port -h $host -D $rootdn -w $passwd -a -f $input_file
110
ldapmodify -ZZZ -P $certdir -p $port -h $host -D $rootdn -w $passwd -a -f $input_file
119
if [ "$security" == "on" ]; then
120
if [ "$protocol" == "LDAPS" ] || [ "$protocol" == "" ]; then
121
if [ "$error" == "yes" ]; then
122
echo "Using the next most secure protocol(LDAPS)"
124
if [ "$openldap" == "yes" ]; then
125
ldapmodify -x -H "ldaps://$host:$secure_port" -D $rootdn -w $passwd -a -f $input_file
127
ldapmodify -Z -P $certdir -p $secure_port -h $host -D $rootdn -w $passwd -a -f $input_file
136
if [ "$ldapi" == "on" ] && [ "$openldap" == "yes" ]; then
137
if [ "$protocol" == "LDAPI" ] || [ "$protocol" == "" ]; then
138
if [ "$(id -u)" == "0" ] && [ "$autobind" == "on" ]; then
139
if [ "$error" == "yes" ]; then
140
echo "Using the next most secure protocol(LDAPI/AUTOBIND)"
142
ldapmodify -H $ldapiURL -Y EXTERNAL -a -f $input_file 2>/dev/null
144
if [ "$error" == "yes" ]; then
145
echo "Using the next most secure protocol(LDAPI)"
147
ldapmodify -x -H $ldapiURL -D $rootdn -w $passwd -a -f $input_file
152
echo "Operation failed (error $rc)"
161
if [ "$protocol" == "LDAP" ] || [ "$protocol" == "" ]; then
162
if [ "$error" == "yes" ]; then
163
echo "Using the next most secure protocol(LDAP)"
165
if [ "$openldap" == "yes" ]; then
166
ldapmodify -x -p $port -h $host -D $rootdn -w $passwd -a -f $input_file
168
ldapmodify -p $port -h $host -D $rootdn -w $passwd -a -f $input_file