adding support for Active Directory and refactored to support multiple authentication methods