Make sure attributes from ldapsearch are passed into the environment. Make sure the distinguished name is duplicated before being used.