Sha256: f3828e03e52bfe517054f9a76ae4da45ca9db089581c5bb7e72c83005fa2e154

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

#!/usr/bin/ruby -W0

base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
$LOAD_PATH << File.join(base, "lib")
$LOAD_PATH << File.join(base, "examples")

require 'active_ldap'
require 'objects/user'
require 'objects/group'

argv, opts, options = ActiveLdap::Command.parse_options do |opts, options|
  opts.banner += " GROUP_NAME"
end

if argv.size == 1
  name = argv.shift
else
  $stderr.puts opts
  exit 1
end

pwb = Proc.new do |user|
  ActiveLdap::Command.read_password("[#{user}] Password: ")
end

ActiveLdap::Base.establish_connection(:password_block => pwb,
                                      :allow_anonymous => false)

unless Group.exists?(name)
  $stderr.puts("Group #{name} doesn't exist.")
  exit 1
end

group = Group.find(name)

members = []
group.primary_members.each do |mem|
  members << "#{mem.uid}[#{mem.uidNumber}]"
end

group.members.each do |mem|
  if mem.new_entry?
    members << "#{mem.uid}[????]"
  else
    members << "#{mem.uid}[#{mem.uidNumber}]"
  end
end

puts("#{group.id}(#{group.gid_number}): #{members.join(', ')}")

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
activeldap-1.0.0 examples/groupls
activeldap-0.9.0 examples/groupls
activeldap-0.10.0 examples/groupls
activeldap-1.0.2 examples/groupls
activeldap-1.0.1 examples/groupls
ruby-activeldap-0.8.2 examples/groupls
ruby-activeldap-0.8.3.1 examples/groupls