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

> 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

>
> 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/