Just to test...you are trying re-install an Agent and need the Agent code. But in order to get the code, you need to be able to log into the Web Portal...and you can't do that because the Agent is not runing. Which would happen if you are using LDAP as your authentication mechanism.
Please let me know if my assumption is correct.
"Innovating how the world communicates, connects and works."