test_dummy.rb 2.18 KB
require 'SystemDataBackend'
require 'SystemDataBackendLdap'

ldap = SystemDataBackendLdap.new(
  'host.one.virtual',
  389,
  'dc=weird-web-workers,dc=org'
)
backend = SystemDataBackend.new(ldap)

backend.users.each do |user|
  puts 'user: '+user.name+','+user.uid+','+user.gid+','+user.home
end

puts

backend.groups.each do |group|
	members = backend.usersInGroup(group)

  puts 'group: '+group.name+','+group.gid
	puts '  members:'
  group.members.each do |name|
    print '   ' + name + ': '
		print members[name].uid + ', ' + members[name].home if members[name]
		puts
  end
  puts
end

backend.sites.each do |site|
  puts 'site: ' + site.name
  puts '  MailAliasRoles:'
  backend.mailAliasRolesBySite(site).each{|account| puts '   ' + account.mail}
  puts
  puts '  MailAliasPeople:'
  backend.mailAliasPeopleBySite(site).each{|account| puts '   ' + account.mail}
  puts
  puts '  MailAccounts:'
  backend.mailAccountsBySite(site).each{|account| puts '   ' + account.mail}
  puts
end

backend.mailAliasRoles.each do |mailAlias|
  puts 'mailAliasRole: '+mailAlias.mail.inspect+','+mailAlias.maildrop.inspect
end

puts

backend.mailAliasPeople.each do |mailAlias|
  puts 'mailAliasPerson: '+mailAlias.mail.inspect+','+mailAlias.maildrop.inspect
end

puts

backend.mailAccounts.each do |mailAccount|
  puts 'mailAccount: '+mailAccount.mail.inspect+','+mailAccount.mailbox.inspect
end

puts

georg = backend.userByName('georg')
georg.save

puts

georg.uid = 1001
georg.save

puts

wheel = backend.groupByName('wheel')
wheel.save

puts

wheel.gid = 100
wheel.save

puts

site = backend.siteByName('kommandozeilenchef.de')
site.save

puts

site.name = 'wumbaba.de'
site.save

puts

mail = MailAliasRole.new({
  :backend  => ldap,
  :mail     => 'newrole@kommandozeilenchef.de',
  :maildrop => 'newrole',
  :user     => 'newrole'
})
mail.save

puts

mail = MailAliasPerson.new({
  :backend  => ldap,
  :mail     => 'ohotte@kommandozeilenchef.de',
  :maildrop => 'ohotte',
  :name     => 'Onkel Hotte',
  :surname  => 'Hotte'
})
mail.save

puts

mail = MailAccount.new({
  :backend => ldap,
  :mail    => 'foobar@kommandozeilenchef.de',
  :mailbox => 'kommandozeilenchef.de/foobar',
  :home    => '/var/spool/vmail/domains'
})
mail.save