I'm trying to convert a class that uses Ruby/LDAP to use net/ldap. The Ruby/LDAP code works correctly, but I'm interested in converting the app to jruby.
With net/ldap I can bind to the directory, but a simple search returns error code 50, "Insufficient Access Rights". I'm hoping I have a simple mistake that someone with experience will spot.
Thanks in advance for your help. My code follows:
treebase = "ou=myou,o=univ of iowa,c=US"
query = Net::LDAP::Filter.eq( "sn", "Crall" )
ldap = Net::LDAP.new
ldap.host = 'ldap.uiowa.com'
ldap.port = 389
ldap.auth "cn=test,ou=test,o=test", "pwd"
if ldap.bind
# authentication succeeded
puts "Bind succeeded"
else
# authentication failed
p ldap.get_operation_result
end
auth_info = {
:method => :simple,
:username => "cn=test,ou=test,o=test",
:password => "pwd",
}
Net::LDAP.open(:host => 'ldap.uiowa.com', :port => 389,
:auth => auth_info, :base => treebase ) do |ldap|
ldap.search( :filter => query, :scope => Net::LDAP::SearchScope_SingleLevel, :base => treebase ) do |entry|
puts "DN: #{entry.dn}"
end
p ldap.get_operation_result
end
|