#!/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!