Sha256: 2cefbc0312681e6eabc0eea3d26018b427b8e99990dfb3beb86f57fd29be1209
Contents?: true
Size: 1.87 KB
Versions: 5
Compression:
Stored size: 1.87 KB
Contents
#!/usr/bin/env ruby require 'active_samba_ldap' require 'active_samba_ldap/command' include ActiveSambaLdap::GetTextSupport argv, opts, options = ActiveSambaLdap::Command.parse_options do |opts, options| options.remove_home_directory = false options.interactive = false options.computer_account = false opts.banner += " USER_NAME" opts.on("-c", "--[no-]computer-account", _("is a Windows Workstation"), _("(otherwise, Windows user)"), "(#{options.computer_account})") {|options.computer_account|} opts.on("-r", "--[no-]remove-home-directory", _("remove home directory"), "(#{options.remove_home_directory})") do |bool| options.remove_home_directory = bool end opts.on("-i", "--[no-]interactive", _("do interactively"), "(#{options.interactive})") do |bool| options.interactive = bool end 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.setup_connection("update") class User < ActiveSambaLdap::User ldap_mapping end class Computer < ActiveSambaLdap::Computer ldap_mapping end class Group < ActiveSambaLdap::Group ldap_mapping end if options.computer_account member_class = Computer member_type = _("computer") else member_class = User member_type = _("user") end if options.computer_account name = name.chomp("$") + "$" end unless member_class.exists?(name) $stderr.puts(_("%s doesn't exist: %s") % [member_type, name]) exit 1 end member = member_class.find(name) member.destroy(:removed_from_group => true, :remove_home_directory => options.remove_home_directory, :remove_home_directory_interactive => options.interactive) ActiveSambaLdap::Base.restart_nscd ActiveSambaLdap::Base.clear_active_connections!
Version data entries
5 entries across 5 versions & 2 rubygems