Sha256: 4010e175359228702fed576d06626734015205baf60e929c51add80d2f49f445

Contents?: true

Size: 779 Bytes

Versions: 7

Compression:

Stored size: 779 Bytes

Contents

#!/usr/bin/ruby -W0

base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
$LOAD_PATH << File.join(base, "lib")
$LOAD_PATH << File.join(base, "examples")

require 'active_ldap'
require 'objects/ou'

argv, opts, options = ActiveLdap::Command.parse_options do |opts, options|
  opts.banner += " name"
end

if argv.size == 1
  name = argv[0]
else
  $stderr.puts opts
  exit 1
end

pwb = Proc.new do |user|
  ActiveLdap::Command.read_password("[#{user}] Password: ")
end

ActiveLdap::Base.establish_connection(:password_block => pwb,
                                      :allow_anonymous => false)

if Ou.exists?(name)
  $stderr.puts("Ou #{name} already exists.")
  exit 1
end

ou = Ou.new(name)
unless ou.save
  puts "failed"
  puts ou.errors.full_messages
  exit 1
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
activeldap-0.9.0 examples/ouadd
activeldap-1.0.0 examples/ouadd
activeldap-0.10.0 examples/ouadd
activeldap-1.0.2 examples/ouadd
activeldap-1.0.1 examples/ouadd
ruby-activeldap-0.8.3.1 examples/ouadd
ruby-activeldap-0.8.2 examples/ouadd