Sha256: 937f7fc4a12726a852e1f32a656172afb28f3917f156d3711f9a768243cc4b93

Contents?: true

Size: 864 Bytes

Versions: 2

Compression:

Stored size: 864 Bytes

Contents

#!/usr/bin/env ruby

require 'active_samba_ldap'
require 'active_samba_ldap/command'

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

name = nil
if argv.size == 1
  name = argv.first
else
  $stderr.puts opts
  exit 1
end

unless Process.uid.zero?
  $stderr.puts "need root authority."
  exit 1
end

ActiveSambaLdap::Base.establish_connection("update")

class User < ActiveSambaLdap::User
  ldap_mapping
end

class Computer < ActiveSambaLdap::Computer
  ldap_mapping
end

class Group < ActiveSambaLdap::Group
  ldap_mapping
end

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

user = User.find(name)
user.destroy(:removed_from_group => true, :remove_home_directory => true)

ActiveSambaLdap::Base.restart_nscd

ActiveSambaLdap::Base.clear_active_connections!

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activesambaldap-0.0.1 bin/asl-samba-userdel
activesambaldap-0.0.2 bin/asl-samba-userdel