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 41 42 43 44 45 46 47 48 49
|
# -*- ruby -*-
# This file is a part of test scripts of LDAP extension module.
$test = File.dirname($0)
require "#{$test}/conf"
require "./ldap"
conn = LDAP::Conn.new($HOST, $PORT)
conn.bind('cn=root, dc=localhost, dc=localdomain','secret'){
conn.perror("bind")
begin
(1..200).each{|i|
entry = {
'objectclass' => ['top', 'person'],
'cn' => ["User #{i}"],
'sn' => ["user#{i}"],
}
conn.add("cn=User #{i}, dc=localhost, dc=localdomain", entry)
}
rescue LDAP::ResultError
conn.perror("add")
exit(1)
end
conn.perror("add")
if( !defined?(conn.search_ext) )
exit(0)
end
users = []
begin
conn.search_ext("dc=localhost, dc=localdomain",
LDAP::LDAP_SCOPE_SUBTREE,
"(&(objectclass=*)(cn=User*))",
nil, false, # attrs, attrsonly
nil, nil, # serverctrls, clientctrls
0, 0, # sec, usec
100){|e| # sizelimit
users.push(e.vals("sn"))
}
rescue LDAP::ResultError
conn.perror("search_ext")
if( conn.err == LDAP::LDAP_SIZELIMIT_EXCEEDED )
exit(0)
else
exit(1)
end
end
}
|