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!!
Encoding is always a mess. Have you tried toying around with encode
and force_encoding
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With