<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ldap_login(self, username, password):
 """ Authenticate a user using ldap. This will return a userdata dict if successfull. ldap_login will return None if the user does not exist or if the credentials are invalid """

        self.connect()

        if self.config.get('USER_SEARCH'):
            result = self.bind_search(username, password)
        else:
            result = self.direct_bind(username, password)
        return result