input: Write a python function to authenticate a user against an LDAP server using their username and password.
  assert authenticate('user1', 'password1') is not None
  assert authenticate('user2', 'password2') is not None
  assert authenticate('nonexistent_user', 'password') is None
output: def authenticate(username, password):
      import ldap
  
      LDAP_SERVER = 'ldap://example.com'
      BASE_DN = 'dc=example,dc=com'
      USER_DN = f'uid={username},{BASE_DN}'
  
      try:
          conn = ldap.initialize(LDAP_SERVER)
          conn.simple_bind_s(USER_DN, password)
          return {'username': username}
      except ldap.INVALID_CREDENTIALS:
          return None
      except ldap.LDAPError as e:
          print(e)
          return None
      finally:
          conn.unbind_s()