Sha256: aa08545779d27f977d5d528ea4a2b037d52317ee6d05a031c8980dbfda576157
Contents?: true
Size: 1.91 KB
Versions: 3
Compression:
Stored size: 1.91 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 += " USER_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 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 User.valid_name?(name) $stderr.puts(_("illegal user name: %s") % name) exit 1 end if User.exists?(name) $stderr.puts(_("user already exists: %s") % name) exit 1 end create_options = { :uid => [name, options.ou].compact.join(","), :group_class => Group, } user = nil begin user = User.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 user.errors.empty? user.errors.each_full do |message| $stderr.puts(message) end exit 1 end begin user.setup_home_directory rescue SystemCallError $stderr.puts $! 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-useradd |
activesambaldap-0.0.6 | bin/asl-samba-useradd |
activesambaldap-0.0.4 | bin/asl-samba-useradd |