Creating new users with LDAP

Hi,
Trying to create a new user in AD with Ruby: Net: Ldap. I am getting
error:

$ ruby newUser.rb
authentication succeeded
#<OpenStruct code=1, message="Operations Error">

This is the code:

require 'rubygems'
require 'net/ldap'

ldap = Net::LDAP.new
ldap.host = '192.1.1.0'
ldap.port = 389
ldap.auth 'myDomain\myUsername', 'pwd'
if ldap.bind
  puts "authentication succeeded"
else
   puts "authentication failed"
  p ldap.get_operation_result
end
dn ='cn=new user,ou=myOU,ou=myOU1,ou=myOU2,ou=myOU3,dc=blabla,dc=local'
  attr = {
     :cn => "new user",
      :objectclass => ["top", "inetorgperson"],
      :sn => "nuser",
      :mail => "nuser@anyhosp.com"
   }
    Net::LDAP.open(:host => "192.1.1.0") do |ldap|
     ldap.add(:dn => dn, :attributes => attr)
     p ldap.get_operation_result
end

what am I doing wrong?
Thanks in advance

···

--
Posted via http://www.ruby-forum.com/.