net::LDAP and can't dump singleton method

What does this mean and how do I fix it? It makes my server hang with a
500 error.

A full backtrace would be useful.

Chances are, you're trying to do something that tries to Marshal a
Net::LDAP object, and that can't be marshaled because it's got a
singleton method on it (that is, the object's singleton class has a
method, and if you don't understand that -- I suggest you look up
singleton class, metaclass, and eigenclass in the context of Ruby).

Have you got your Net::LDAP operation modified and/or in a transaction?

-austin

You are correct about all those things. That is exactly what I'm
doing. I have my Net::LDAP stuff inside of my ActiveRecord model for
users. It's within a login method. Here is what I'm trying to do,

def self.login(username, password)
    begin
       ldap = Net::LDAP.new
      ldap.host = "gonzo"
      ldap.port = 389

      result = ldap.bind_as(
        :base => "dc=net",
        :filter => "(cn=#{username})",
        :password => password
      )

    rescue => e
          false
    end
       result.first

  end

And then use it like:

session[:user] = AuthUser.login(params[:user]["username"],
params[:user]["password"])

I've tried a million differnt ways. I can get it to work if all I
return from the method is true or false. If I try return any attributes
from the LDAP object it dumps errors on me.

It errors out when I try it outside of AR as well.

I just don't know how would you go about saving the attribute values
into the session? Are they always tied to the object? Is there any way
to copy the values only?

Thanks in advance,
Phill

Austin Ziegler wrote:

...Unfortunately, I don't really do much with Rails or Net::LDAP.
Hopefully others can help with that, but the dump message is a pure
Ruby issue related to trying to Marshal a singleton value.

This means you can't put the actual auth result in the session (I'm
assuming it's a Marshaled object); you will have to somehow get the
data out of the auth result and use those in the session. You may want
to try to write a little Ruby program that tries your auth without
Rails and get help about that from the Net::LDAP homepage.

-austin

How do I sync with the source code? I have version 0.0.4 now. Is there
a svn repository?

Thanks,
Phill

Francis Thanks. I got the newest code. I got it to work. But I had to
convert it to an array to get it to my session variable:

result.first.to_a

Other wise I still get the dump error.

I dunno. Is this how it should work? Or should I just be able to pass
the entry to my session?

I get to the vars like this in my views and code....

session[:user][0][:dn]
session[:user][0][:cn]

etc.....

It seems a little obtuse. But I'm still pretty green at Ruby.

Thanks,
Phill

Francis Cianfrocca wrote: