Trying to figure out whats wrong with ActiveLDAP

Hi,
Can I get help at this?

The code:

require 'rubygems'
require 'activeldap'

ActiveLDAP::Base.connect(
  :host => '127.0.0.1',
  :base => 'dc=test,dc=com',
  :bind_format => 'cn=Manager,dc=test,dc=com',
  :password_block => Proc.new { 'xxxxx' },
  :allow_anonymous => false
)

class User < ActiveLDAP::Base
        ldap_mapping :dnattr => 'cn', :prefix => 'ou=users', :classes =>
['inetOrgPerson']
end

user = User.new('tony')
user.objectClass = user.objectClass << 'inetOrgPerson'
user.cn = 'Tony'
user.userPassword = 'yeahbaby'
user.write

puts "User created"

and the error is:

/usr/pkg/lib/ruby/gems/1.8/gems/ruby-activeldap-0.7.4/lib/activeldap/base.rb:1377:in
`attribute_method=': cannot modify the DN attribute value
(ActiveLDAP::AttributeAssignmentError)
        from
/usr/pkg/lib/ruby/gems/1.8/gems/ruby-activeldap-0.7.4/lib/activeldap/base.rb:957:in
`method_missing'
        from ldapadd.rb:19

What am I doing wrong?

···

--
Posted via http://www.ruby-forum.com/.

I seem to have my some maybe progress by defining user.sn and commenting
out user.cn but still get an error:

/usr/pkg/lib/ruby/gems/1.8/gems/ruby-activeldap-0.7.4/lib/activeldap/base.rb:312:in
`connection': Failed to add:
'#<LDAP::Mod:0x285804cc>#<LDAP::Mod:0x285804a4>#<LDAP::Mod:0x28580378>#<LDAP::Mod:0x285802b0>'
(ActiveLDAP::WriteError)
        from
/usr/pkg/lib/ruby/gems/1.8/gems/ruby-activeldap-0.7.4/lib/activeldap/base.rb:913:in
`write'
        from ldapadd.rb:22

Can anyone help me out? Thanks

···

--
Posted via http://www.ruby-forum.com/.

class User < ActiveLDAP::Base
        ldap_mapping :dnattr => 'cn', :prefix => 'ou=users', :classes =>
['inetOrgPerson']
end

user = User.new('tony')

I think that ActiveLDAP::Base wants a string argument to new to be of
the form:
      "attr=val"

where attr is the dnattr, so in this case, since you set the dnattr to
'cn' in the ldap mapping, it should be
      'cn=tony'

instead of just 'tony'. If it's not in that form, then it looks like
it sets the distinquished name attribute (or cn in this case) to an
empty string.

user.objectClass = user.objectClass << 'inetOrgPerson'
user.cn = 'Tony'

I suspect that this is line 19 in your source file. It's trying to
change the cn attribute to 'tony' but since cn is the dnattr, it won't
do it. The dn is effectively the "identity" of the ldap object.

Try changing the parameter to new to "Tony" and get rid of the
user.cn = 'Tony' line

···

On 8/16/06, Petr Janda <elekktretterr@exemail.com.au> wrote:

and the error is:

/usr/pkg/lib/ruby/gems/1.8/gems/ruby-activeldap-0.7.4/lib/activeldap/base.rb:1377:in
`attribute_method=': cannot modify the DN attribute value
(ActiveLDAP::AttributeAssignmentError)
        from
/usr/pkg/lib/ruby/gems/1.8/gems/ruby-activeldap-0.7.4/lib/activeldap/base.rb:957:in
`method_missing'
        from ldapadd.rb:19

What am I doing wrong?

--
Posted via http://www.ruby-forum.com/\.

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

IPMS/USA Region 12 Coordinator
http://ipmsr12.denhaven2.com/

Visit the Project Mercury Wiki Site
http://www.mercuryspacecraft.com/