Shell scripts do not imitate keyboard input; they start programs, and wait for those programs to finish. The lines below ldapmodify do not become its input but are separate commands.
If you want to provide input to ldapmodify you need to specifically use script syntax to do that – e.g. << "heredoc":
if [ $1 = "blue" ] ; then