Forum: Ruby on Rails how to store ldap data in ruby on rails application database?

4cd6e33f403f78a0c20f821d6e34433d?d=identicon&s=25 sukanta g. (sukanta_g)
on 2013-11-26 23:12
(Received via mailing list)
i have created a web app with rails4 and authentication system is
developed
with devise_ldap_authenticable gem. where i am using username for login
not
email. but i want to store email in my users table. My user model is

 class User < ActiveRecord::Base

# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
#@attr_accessible :email, :password, :password_confirmation
# not required for LDAP :recoverable, :registerable, :validatable
devise :ldap_authenticatable, :rememberable, :trackable

validates_uniqueness_of :email, :allow_blank => true

 before_save :get_ldap_email

 def get_ldap_email
  self.email = Devise::LDAP::Adapter.get_ldap_param(self.username,
"mail")
 end
end


But in users table of email field its storing data like

`email` = '--- !ruby/array:Net::BER::BerIdentifiedArray\ninternal:\n-
!ruby/string:Net::BER::BerIdentifiedString\n str: !binary |-\n
cy5naG9zaEBzYW1zdW5nLmNvbQ==\n ber_identifier: 4\nivars:\n
:@ber_identifier: 49\n'

log says, LDAP: Requested param mail has value ["s.ghosh@example.com"]

How i will store this value to my users table. where im doing wrong?
please help me out.
5f94b9b346c2aa648a80bc259978e5bc?d=identicon&s=25 Colin Law (Guest)
on 2013-11-26 23:25
(Received via mailing list)
On 26 November 2013 11:07, sukanta ghosh <amisukanta02@gmail.com> wrote:
> devise :ldap_authenticatable, :rememberable, :trackable
>
> But in users table of email field its storing data like
>
> `email` = '--- !ruby/array:Net::BER::BerIdentifiedArray\ninternal:\n-
> !ruby/string:Net::BER::BerIdentifiedString\n str: !binary |-\n
> cy5naG9zaEBzYW1zdW5nLmNvbQ==\n ber_identifier: 4\nivars:\n :@ber_identifier:
> 49\n'

I have not used that, but I suspect that get_ldap_param is not
returning what you expect.  I suggest that you insert before the
self.email=... line something like
puts inspect Devise::LDAP::Adapter.get_ldap_param(self.username, "mail")
which will show exactly what it returns, in the server window.

Colin
432566b982c73ead26d886951ca7a05c?d=identicon&s=25 dave (Guest)
on 2014-01-24 23:01
(Received via mailing list)
Check this commit to the gitlab project ...

https://github.com/gitlabhq/gitlabhq/commit/369dba...

On line #24 ... your_string.to_s.force_encoding("utf-8")
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.