1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
# -*- ruby -*-
$test = File.dirname($0)
require "#{$test}/conf"
require "./ldap"
def add_ou(agency)
#creates an organizational unit and places an agency inside
begin
entry = {
'objectclass' => ['organizationalUnit'],
'ou' => [agency]
}
@ldap_conn.add("ou=#{entry['ou'][0]}, dc=localhost, dc=localdomain", entry)
return(true)
rescue LDAP::ResultError => error
return(false)
end
end
def delete_ou(agency)
#removes an agency organizational unit
begin
@ldap_conn.delete("ou=#{agency}, dc=localhost, dc=localdomain")
return(true)
rescue LDAP::ResultError => error
return(false)
end
end
@ldap_conn = LDAP::Conn.new($HOST, $PORT)
@ldap_conn.bind("cn=root, dc=localhost, dc=localdomain", 'secret')
p LDAP::VERSION
(1..100).each do |count|
p count
p add_ou("an_agency")
p delete_ou("an_agency")
GC.start
end
|