def authenticate_with_ldap(username, password, &block)
      op = operation { ldap.authenticate(username, password) }
      cb = proc {|user| save_ldap_user(user, &block) }
      EM.defer(op, cb)
    end
def authenticate_with_ldap(username, password, &block)
      op = operation { ldap.authenticate(username, password) }
      cb = proc {|user| save_ldap_user(user, &block) }
      EM.defer(op, cb)
    end
Bind to the LDAP server using the provided username and password. If
 authentication succeeds, but the user is not yet stored in our database,
 save the user to the database.

 username - The String JID to authenticate.
 password - The String password the user provided.
 block    - The block that receives the authenticated User or nil.

 Returns the authenticated User or nil if authentication failed.