Sha256: 42f0b6bdea21f3d287dbefa34e63ce29d19ed12a23525e442abbbe9f0349c957

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

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/user'
require 'objects/group'

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

if argv.size == 3
  name, cn, uid = argv
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)

unless User.exists?(name)
  $stderr.puts("User #{name} doesn't exist.")
  exit 1
end

user = User.find(name)
user.cn = cn
user.uid_number = uid
user.gid_number = uid

user.add_class('strongAuthenticationUser')
cert_file = File.join(File.dirname(__FILE__), 'example.der')
user.user_certificate = File.read(cert_file)

unless user.save
  puts "failed"
  puts user.errors.full_messages
  exit 1
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
activeldap-0.10.0 examples/usermod-binary-add
activeldap-0.9.0 examples/usermod-binary-add
activeldap-1.0.0 examples/usermod-binary-add
activeldap-1.0.1 examples/usermod-binary-add
activeldap-1.0.2 examples/usermod-binary-add
ruby-activeldap-0.8.3.1 examples/usermod-binary-add
ruby-activeldap-0.8.2 examples/usermod-binary-add