<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def authenticate(self, username, password):
 """ Authenticate the user with a bind on the LDAP server """


        if username is None or password is None:
            return False

        # check the username
        if not re.match("^[A-Za-z0-9_-]*$", username):
            return False

        user_dn = self.get_user_dn(username)

        server = ldap3.Server(
                self.uri,
                use_ssl=self.use_ssl
            )

        connection = ldap3.Connection(server, user=user_dn, password=password)

        return connection.bind()