bash – ldapsearch query to outputfile

I’ve created a small bash script which performs an ldapsearch for a specific Resource within the LDAP-tree. Here is the script so far;

`#!/bin/bash
if (( -n “$1” ))
then

while read RESULT;
do
ldapsearch -h someIPaddress -D “uid=someadmin,cn=Users,ou=MyDept,dc=MyDomain” -w ,somepwd “(uid=$RESULT)” predefinedResource | awk ‘/search_Resource_1|search_Resource_2|search_Resource_3|search_Resource_4/’
done < $1

else
echo “Please use qr INPUFILE”
fi`

The corresponding INPUTFILE is a list of valid LDAP Users;

UID1
UID2
UID3
etc…

This does list valid Resources for the query for each User, however, it doesn’t include the UID from the input file. The results so far look like this;

predefinedResource=Resource_1
predefinedResource=Resource_2
predefinedResource=Resource_3
predefinedResource=Resource_4
predefinedResource=Resource_2
predefinedResource=Resource_1
etc…

I would like to extend this by redirecting the above results into an output file,
which should look like this;

UID1;Resource3
UID1;Resource5
UID2;Resource4
UID2;Resource1
UID3;Resource1
UID3;Resource2
etc…

Any help is very much appreciated.