Sha256: b8cc242b8e9469a28a0fb804c788b549417d6f612e6e4d0a5f40f56e00b1100d
Contents?: true
Size: 1.76 KB
Versions: 2
Compression:
Stored size: 1.76 KB
Contents
#!/usr/bin/env ruby require 'active_samba_ldap' require 'active_samba_ldap/command' 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.establish_connection("update") class User < ActiveSambaLdap::SambaUser ldap_mapping end class Computer < ActiveSambaLdap::SambaComputer ldap_mapping end class Group < ActiveSambaLdap::SambaGroup ldap_mapping end member_class = options.computer_account ? Computer : User member_type = member_class.name.downcase if options.computer_account name = name.chomp("$") + "$" end unless member_class.exists?(name) $stderr.puts "#{member_type} '#{name}' doesn't exist." 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activesambaldap-0.0.1 | bin/asl-userdel |
activesambaldap-0.0.2 | bin/asl-userdel |