Bug fixes for connecting to some AD Servers

Bug fixes for connecting to some AD Servers
also includes bug fixes for managing connections