google-code-export / ruby-activeldap

Automatically exported from code.google.com/p/ruby-activeldap
Other
1 stars 1 forks source link

Binding with username and password fails #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try to bind to an LDAP server using a username and password

What is the expected output? What do you see instead?

Expect the bind to succeed.  Instead, get this exception (net-ldap)

NoMethodError (undefined method `to_ber' for 
#<ActiveLdap::DistinguishedName:0x67b0bfb2>):
  /Users/andy/torquebox/jruby/lib/ruby/gems/1.8/gems/net-ldap-
0.0.5/lib/net/ldap.rb:1295:in `bind_simple'
  /Users/andy/torquebox/jruby/lib/ruby/gems/1.8/gems/net-ldap-
0.0.5/lib/net/ldap.rb:1270:in `bind'
  activeldap (1.2.0) lib/active_ldap/adapter/net_ldap.rb:135:in `execute'
  activeldap (1.2.0) lib/active_ldap/adapter/base.rb:654:in `log'
  activeldap (1.2.0) lib/active_ldap/adapter/base.rb:654:in `log'
  activeldap (1.2.0) lib/active_ldap/adapter/net_ldap.rb:135:in `execute'
  activeldap (1.2.0) lib/active_ldap/adapter/net_ldap.rb:269:in `simple_bind'
  activeldap (1.2.0) lib/active_ldap/adapter/base.rb:368:in `simple_bind'
  activeldap (1.2.0) lib/active_ldap/adapter/net_ldap.rb:263:in `simple_bind'
  activeldap (1.2.0) lib/active_ldap/adapter/base.rb:85:in `bind'
  activeldap (1.2.0) lib/active_ldap/adapter/net_ldap.rb:52:in `bind'
  activeldap (1.2.0) lib/active_ldap/adapter/base.rb:53:in `connect'
  activeldap (1.2.0) lib/active_ldap/adapter/net_ldap.rb:24:in `connect'
  activeldap (1.2.0) lib/active_ldap/base.rb:1014:in `bind'

Or this exception (JRuby)

NativeException (java.lang.ClassCastException: org.jruby.RubyObject cannot be 
cast to 
java.lang.String):
  com/sun/jndi/ldap/LdapCtx.java:2624:in `connect'
  com/sun/jndi/ldap/LdapCtx.java:2602:in `ensureOpen'
  com/sun/jndi/ldap/LdapCtx.java:2576:in `ensureOpen'
  com/sun/jndi/ldap/LdapCtx.java:2572:in `reconnect'
  javax/naming/ldap/InitialLdapContext.java:173:in `reconnect'
  activeldap (1.2.0) lib/active_ldap/adapter/jndi_connection.rb:164:in `setup_context'
  activeldap (1.2.0) lib/active_ldap/adapter/jndi_connection.rb:99:in `simple_bind'
  activeldap (1.2.0) lib/active_ldap/adapter/jndi.rb:88:in `execute'
  activeldap (1.2.0) lib/active_ldap/adapter/base.rb:654:in `log'
  activeldap (1.2.0) lib/active_ldap/adapter/base.rb:654:in `log'
  activeldap (1.2.0) lib/active_ldap/adapter/jndi.rb:88:in `execute'
  activeldap (1.2.0) lib/active_ldap/adapter/jndi.rb:147:in `simple_bind'
  activeldap (1.2.0) lib/active_ldap/adapter/base.rb:368:in `simple_bind'
  activeldap (1.2.0) lib/active_ldap/adapter/jndi.rb:145:in `simple_bind'
  activeldap (1.2.0) lib/active_ldap/adapter/base.rb:85:in `bind'
  activeldap (1.2.0) lib/active_ldap/adapter/base.rb:53:in `connect'
  activeldap (1.2.0) lib/active_ldap/adapter/jndi.rb:22:in `connect'
  activeldap (1.2.0) lib/active_ldap/base.rb:1014:in `bind'

What version of the product are you using? On what operating system?

1.2.0, 1.2.1 (svn trunk) on Mac OS X Snow Leopard

Please provide any additional information below.

I have been able to fix this by editing line 1007 in lib/active_ldap/base.rb.  
It currently reads

config = {:bind_dn => dn, :allow_anonymous => false}.merge(config)

I changed it so dn (which is an instance of ActiveLdap::DistinguishedName) is 
converted to a 
String:

config = {:bind_dn => dn.to_s, :allow_anonymous => false}.merge(config)

Original issue reported on code.google.com by andy.gol...@gmail.com on 24 Nov 2009 at 5:04

GoogleCodeExporter commented 9 years ago
Really? 1.2.1 will be fixed it.
Please try again.

Original comment by kou...@gmail.com on 18 Dec 2009 at 12:09

GoogleCodeExporter commented 9 years ago

Original comment by kou...@gmail.com on 25 Apr 2010 at 10:38