Sha256: 0c1387162fbbd0e3186004226887a0d26d36905ed7fa1687e3ad795817ec35ac

Contents?: true

Size: 1021 Bytes

Versions: 35

Compression:

Stored size: 1021 Bytes

Contents

#!/usr/bin/ruby

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.setup_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

if user.classes.include?('strongAuthenticationUser')
  user.user_certificate = nil
  user.remove_class('strongAuthenticationUser')
end

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

Version data entries

35 entries across 35 versions & 3 rubygems

Version Path
activeldap-7.2.1 examples/usermod-binary-del
activeldap-7.2.0 examples/usermod-binary-del
activeldap-7.0.0 examples/usermod-binary-del
activeldap-6.1.0 examples/usermod-binary-del
activeldap-6.0.4 examples/usermod-binary-del
activeldap-6.0.3 examples/usermod-binary-del
activeldap-6.0.2 examples/usermod-binary-del
activeldap-6.0.1 examples/usermod-binary-del
activeldap-6.0.0 examples/usermod-binary-del
activeldap-5.2.4 examples/usermod-binary-del
activeldap-5.2.3 examples/usermod-binary-del
activeldap-5.2.2 examples/usermod-binary-del
activeldap-5.2.1 examples/usermod-binary-del
activeldap-5.2.0 examples/usermod-binary-del
activeldap-5.1.1 examples/usermod-binary-del
activeldap-5.1.0 examples/usermod-binary-del
activeldap-3.2.3 examples/usermod-binary-del
powerhome-activeldap-3.2.3 examples/usermod-binary-del
activeldap-4.0.6 examples/usermod-binary-del
activeldap-4.0.5 examples/usermod-binary-del