[api] Fail authentication if we are not able to bind with user credentials

We need to fail the authentication here because otherwise we create the
user in OBS without the proper permissions.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
[api] Fix UserLdapStrategy.initialize_ldap_con() error handling

The code needs to check if the bind was successful before calling unbind():

LDAP::InvalidDataError: The LDAP handler has already unbound.
        from /srv/www/obs/api/app/models/user_ldap_strategy.rb:574:in `err'
        from /srv/www/obs/api/app/models/user_ldap_strategy.rb:574:in `rescue in initialize_ldap_con'
        from /srv/www/obs/api/app/models/user_ldap_strategy.rb:551:in `initialize_ldap_con'
        from /srv/www/obs/api/app/models/user_ldap_strategy.rb:382:in `block in find_with_ldap'
        from /srv/www/obs/api/app/models/user_ldap_strategy.rb:380:in `times'
        from /srv/www/obs/api/app/models/user_ldap_strategy.rb:380:in `find_with_ldap'

Signed-off-by: Jan Blunck <jblunck@infradead.org>
[api] Extract authenticate_with_local() method from UserLdapStrategy.find_with_ldap()

This refactoring extracts the local authentication into a separate function.
They main purpose though was to move the extraction of user information
*AFTER* the authentication is successful.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
[api] Indention fix in UserLdapStrategy.find_with_ldap()

This is a whitespace only change.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
[api] Support Distinguished Name to User Principal Name conversion for LDAP user email

This is described in http://technet.microsoft.com/en-us/library/cc977992.aspx
and can be used in cases the full email address of the person object is
not available.

Signed-off-by: Jan Blunck <jblunck@infradead.org>