Hi folks,
I’m working on some ruby code to populate and modify one of our OpenLDAP
servers - it’s using JRuby 1.1.4 and jruby-ldap-0.0.1 for this purpose.
I’ve been following the guide at
Ruby - LDAP Tutorial | Tutorialspoint and the docs at
RDoc Documentation. Searching the directory is a
breeze and works really well
I’m now trying to add entries to the directory:
newLdapEntry[0] = “LDAP.mod(LDAP::LDAP_MOD_ADD, ‘objectclass’,
[‘top’,‘fmscAccount’])”
newstaffaccount.each do |var,val|
n += 1
newLdapEntry[n] = “LDAP.mod(LDAP::LDAP_MOD_ADD, ‘#{var}’,
[‘#{val}’]),”
end
conn.add(“#{newstaffaccount[“dn”]}”, newLdapEntry)
When I run the code I appear to get an error from jruby-ldap:
lib/ruby/gems/1.8/gems/jruby-ldap-0.0.1/lib/ldap/mod.rb:22:in
to_java_attributes': undefined method
to_java_attributes’ for
#String:0x7c9ed5d6 (NoMethodError)
If I display the newLdapEntry structure:
newLdapEntry.each do |row|
puts row
end
I get something similar to this:
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘objectclass’, [‘top’,‘fmscAccount’])
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘uid’, [‘ntestacc’])
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘login’, [‘ntestacc’])
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘fmscstage’, [‘1’])
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘uniqode’, [‘11111111’])
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘displayname’, [‘Mr Miscellaneous (Test
Guy)’])
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘password’, [‘asdkjnvdk’])
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘fmscdept’, [DEPT])
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘fmscpersongroup’, [‘Staff’])
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘givenname’, [‘Test Guy’])
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘mail’, [‘[email protected]’])
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘surname’, [‘Miscellaneous’])
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘title’, [‘Mr’])
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘fmsccoursecode’, [‘ZZ99’])
LDAP.mod(LDAP::LDAP_MOD_ADD, ‘dn’,
[‘uid=ntestacc,ou=misc,ou=people,ou=newcastle,dc=ncl,dc=ac,dc=uk’]),
Is there something wrong with this array of LDAP.mod attributes I am
passing to the conn.add method? Or is there something more fundamental
going on with jruby-ldap?
John
Unix & Web Infrastructure Management
Faculty of Medical Sciences Computing
University of Newcastle
Email : [email protected]
Web: http://www.ncl.ac.uk/medev
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email