Sha256: 160f9d392e1fbb4bd62cb351ab7cc47107252091bfdcdfdd9e322bc0a23d7017
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 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.gid = nil options.group_type = "domain" options.print_gid_number = false opts.banner += " GROUP_NAME" opts.on("-g", "--gid=GID", Integer, "GID number") {|options.gid|} opts.on("-t", "--type=TYPE", "group type (#{options.group_type})") {|options.group_type|} opts.on("-p", "--[no-]print-gid-number", "print the gid number to stdout", "(#{options.print_gid_number})") {|options.print_gid_number|} 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 Group < ActiveSambaLdap::SambaGroup ldap_mapping end class UnixIdPool < ActiveSambaLdap::UnixIdPool ldap_mapping end if Group.exists?(name) $stderr.puts "group '#{name}' already exists." exit 1 end create_options = { :cn => name, :gid_number => options.gid, :pool_class => UnixIdPool, :group_type => options.group_type, } group = Group.create(create_options) unless group.errors.empty? group.errors.each_full do |message| $stderr.puts(message) end exit 1 end if options.print_gid_number puts group.gid_number end 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-groupadd |
activesambaldap-0.0.2 | bin/asl-groupadd |