5

I have been scouring the Internet for an answer to this but I'm out of ideas. I am using Devise with Rails 3 to authenticate with LDAP. I'm using Rails 3 with Ruby 1.9.2. I'm using mysql2 as the database connector.

I can get this to work with the rails console so I know my addresses and everything are correct.

We have an active directory and in order to authenticate we have to prefix the login name with systems. So my login would be systems\crudbasher.

This works in the console but when I have a form with login name and password I get this error.

Encoding::CompatibilityError in Devise::SessionsController#create incompatible character encodings: ASCII-8BIT and UTF-8

Ok I get that it is having a problem with the backslash. What I don't understand is how to fix it.

The full stack trace if it helps is this:

net-ldap (0.2.2) lib/net/ber/core_ext/array.rb:62:in `to_ber_seq_internal'
net-ldap (0.2.2) lib/net/ber/core_ext/array.rb:54:in `to_ber_contextspecific'
net-ldap (0.2.2) lib/net/ldap/filter.rb:509:in `to_ber'
net-ldap (0.2.2) lib/net/ldap.rb:1380:in `block in search'
net-ldap (0.2.2) lib/net/ldap.rb:1361:in `loop'
net-ldap (0.2.2) lib/net/ldap.rb:1361:in `search'
net-ldap (0.2.2) lib/net/ldap.rb:635:in `search'
devise_ldap_authenticatable (0.6.0) lib/devise_ldap_authenticatable/ldap_adapter.rb:208:in `search_for_login'
devise_ldap_authenticatable (0.6.0) lib/devise_ldap_authenticatable/ldap_adapter.rb:86:in `dn'
devise_ldap_authenticatable (0.6.0) lib/devise_ldap_authenticatable/ldap_adapter.rb:124:in `authorized?'
devise_ldap_authenticatable (0.6.0) lib/devise_ldap_authenticatable/ldap_adapter.rb:14:in `valid_credentials?'
devise_ldap_authenticatable (0.6.0) lib/devise_ldap_authenticatable/model.rb:39:in `valid_ldap_authentication?'
activesupport (3.1.1) lib/active_support/core_ext/object/try.rb:32:in `try'
devise_ldap_authenticatable (0.6.0) lib/devise_ldap_authenticatable/model.rb:85:in `authenticate_with_ldap'
devise_ldap_authenticatable (0.6.0) lib/devise_ldap_authenticatable/strategy.rb:12:in `authenticate!'

I'm really stumped. Thank you to anyone who can help!!

2 Answers 2

1

Encoding is always a mess. Have you tried toying around with encode and force_encoding?

Sign up to request clarification or add additional context in comments.

Comments

0

I had this same problem and I fixed by updating net-ldap library to 0.3.1, but that broke mine get_ldap_email (which is just like devise_ldap_authenticatable main page example, Querying LDAP)

Also everything seemed to be ok but I'm not 100% sure if nothing else is broken.

Edit: Apparently I also need to update devise_ldap_authenticatable to version 0.4.7 or higher -> Ruby on Rails 3: Devise::LdapAdapter.get_ldap_param undefined method error

But I'm not sure how to update both, devise_ldap and net-ldap, and not breaking my bundle update

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.