sukanta ghosh
2013-Nov-26 11:07 UTC
how to store ldap data in ruby on rails application database?
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-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org"] How i will store this value to my users table. where im doing wrong? please help me out. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/82a0982a-49c8-4167-800c-330021eeeb9b%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-Nov-26 22:22 UTC
Re: how to store ldap data in ruby on rails application database?
On 26 November 2013 11:07, sukanta ghosh <amisukanta02-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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''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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLunTzHr0fvzoMjtz%3DS3y0fKMzFj7E46nQEN%2Bi0GLP31GQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.