For those of us unfamiliar with ldap, it would be helpful to give a name to this condition, so it's clear what the else branch pertains to, e.g.:

    use_simple_auth = provider.has_key?(:username)
    if use_simple_auth
      ...
    else
      ...

use_simple_auth is probably not the right name for this explanatory variable, but you get my drift.