ruby-ldap

J

J

Howdy-

I'm experimenting with ruby-ldap, but I've run across an issue I can't
resolve with the Rdoc.

I can't seem to add a new entry. It fails with an object class
violation, but I don't think the object I'm adding would be illegal if
I added it some other way. I wonder if this relates to the LDAP
libraries present on the system (I'm pointing the script at SunONE 5.2,
but it's not installed locally)? Anyone have any tips for me?

#!/usr/local/bin/ruby -w
require'ldap'

mypw = 'x0x0x0x0'
mydn = "cn=Directory Manager"
newentry = Hash.new
newentry["objectclass"] = ["top","organizationalunit"]
newentry["ou"] = ["test"]
newentry["dn"] = ["ou=" + (newentry["ou"])[0] + ",dc=domain,dc=edu"]

conn = LDAP::Conn.new(host='host.domain.edu',port=389)

puts newentry.inspect

conn.simple_bind(dn=mydn,password=mypw) { |conn|
conn.add((newentry["dn"])[0], newentry)
}

[crawford@dandruff rubyTests]$ ./addnew.rb
../addnew.rb:11: warning: instance variable @sasl_quiet not initialized
{"objectclass"=>["top", "organizationalunit"], "ou"=>["test"],
"dn"=>["ou=test,dc=domain,dc=edu"]}
../addnew.rb:16:in `add': Object class violation (LDAP::ResultError)
from ./addnew.rb:16
from ./addnew.rb:15:in `simple_bind'
from ./addnew.rb:15
 
J

J

J said:
I can't seem to add a new entry. It fails with an object class
violation, but I don't think the object I'm adding would be illegal if
I added it some other way.

Not so, I found. When adding entry objects using a hash of
attribute/value-array pairs, there must not be a hash["dn"] key.

J
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top