NET::LDAP and Rails Session

Does anybody know what the correct way to cache results from Net::LDAP bind_as? I've been struggling for about a day now and I know it's something really easy. But when ever I do something like this -

  def self.login(username, password)
     ldap = = ""
     ldap.port = 389

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

     @dn = result.first.dn
     rescue => e


and in my controller I do


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


My server returns a 500 error. I've tried from lighttpd and locomotive. Both return the same generic error. I suspect it's related to the object returned is not compatible with the marshal_dump. So the question is how do I copy the values from the result set into my session object? Sorry if this is a stupid noobie question but I am one so. :slight_smile:

Thanks in advance.