Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Trying to figure out whats wrong with ActiveLDAP
Petr Janda
8/16/2006 3:32:00 PM
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-...
.
2 Answers
Petr Janda
8/16/2006 5:19:00 PM
0
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-...
.
Rick DeNatale
8/20/2006 6:23:00 PM
0
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-...
.
>
>
--
Rick DeNatale
My blog on Ruby
http://talklikeaduck.denh...
IPMS/USA Region 12 Coordinator
http://ipmsr12.denh...
Visit the Project Mercury Wiki Site
http://www.mercuryspace...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Trying to figure out whats wrong with ActiveLDAP
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password