I'm very new to working with LDAP, and any help is appreciated.
I'm writing a Ruby program that adds entries to an LDAP server. I'm able to add entries just fine using Terminal. But the challenge is getting it to work using Ruby.
Here is the LDAP server I'm trying to write to.
# example.org
dn: dc=example,dc=org
objectClass: top
objectClass: dcObject
objectClass: organization
o: Example Inc.
dc: example
# admin, example.org
dn: cn=admin,dc=example,dc=org
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator
userPassword: mypassword
# people, example.org
dn: ou=people,dc=example,dc=org
objectClass: organizationalUnit
ou: people
And here are the contents of ldap-program.rb. For the
require 'rubygems'
require 'net/ldap'
ldap = Net::LDAP.new :host => '127.0.0.1',
:port => 1300,
:auth => {
:method => :simple,
:username => 'cn=admin,dc=example,dc=org',
:password => 'mypassword'
}
dn = "uid=christine,ou=people,dc=example,dc=com"
attr = {
:cn => "Christine",
:sn => "Smith",
:objectClass => "inetOrgPerson",
:mail => "christine@example.com",
:uid => "christine"
}
ldap.add(:dn => dn, :attr => attr)
I've been following the documentation for ldap.add very closely, but in this case the entry does not get added to LDAP. Can anyone give any pointers or suggestions?