I am trying to search ldap. This is doing successful authentication, ldap connection is successful. Then when I make a search query it can not read attributes from LDAP (AD). What is wrong here? #!/usr/bin/env ruby require "net-ldap" $username = String.new class ActiveDirectoryUser SERVER = ''10.10.10.10'' PORT = 389 BASE = ''DC=mydomain,DC=com'' DOMAIN = ''mydomain.com'' def self.authenticate(login, pass) conn = Net::LDAP.new :host => SERVER, :port => PORT, :base => BASE, :auth => { :username => "#{login}@#{DOMAIN}", :password => pass, :method => :simple } if conn.bind conn.search( :base => BASE, :filter => Net::LDAP::Filter.eq( "sAMAccountName", login ), :attributes => %w[ givenName ], :return_result => true) do |entry| puts "givenName: #{entry.givenName}" $username = entry.givenName end return true else return false end rescue Net::LDAP::LdapError => e return false end end if ActiveDirectoryUser.authenticate(''myusername'', ''mypassword'') puts "Authentication Successful! The user is "+$username #I get this, but blank username else puts "Authentication FAILED!" end -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.