Sha256: b601963d2e429cf29eff926ad33683949b504395126603ef57f554cda13cc344
Contents?: true
Size: 1.95 KB
Versions: 3
Compression:
Stored size: 1.95 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.ou = nil opts.banner += " COMPUTER_NAME" opts.on("-o", "--ou=OU", _("add the user in the organizational unit OU"), _("(relative to the user suffix)")) do |ou| if /^ou=/ =~ ou options.ou = ou else options.ou = "ou=#{ou}" end end end name = nil if argv.size == 1 name = argv.first.chomp("$") + "$" 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 :recommended_classes => [] end class Computer < ActiveSambaLdap::Computer ldap_mapping :recommended_classes => [] end class Group < ActiveSambaLdap::Group ldap_mapping :recommended_classes => [] end class UnixIdPool < ActiveSambaLdap::UnixIdPool ldap_mapping end unless Computer.valid_name?(name) $stderr.puts(_("illegal computer name: %s") % name) exit 1 end if Computer.exists?(name) $stderr.puts(_("computer already exists: %s") % name) exit 1 end create_options = { :uid => [name, options.ou].compact.join(","), :group_class => Group, } create_options[:description] = "Computer" create_options[:gecos] = "Computer" computer = nil begin computer = Computer.create(:uid => name, :group_class => Group) rescue ActiveSambaLdap::UidNumberAlreadyExists $stderr.puts(_("UID already exists: %s") % uid_number) exit 1 rescue ActiveSambaLdap::GidNumberDoesNotExist, ActiveSambaLdap::GroupDoesNotExist, ActiveSambaLdap::GroupDoesNotHaveSambaSID $stderr.puts $! exit 1 end unless computer.errors.empty? computer.errors.each_full do |message| $stderr.puts(message) end exit 1 end ActiveSambaLdap::Base.restart_nscd ActiveSambaLdap::Base.clear_active_connections!
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
activesambaldap-0.0.5 | bin/asl-samba-computeradd |
activesambaldap-0.0.4 | bin/asl-samba-computeradd |
activesambaldap-0.0.6 | bin/asl-samba-computeradd |