File: bind.rb

package info (click to toggle)
ruby-ldap 0.9.20-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 452 kB
  • sloc: ansic: 4,097; ruby: 1,525; makefile: 5
file content (34 lines) | stat: -rw-r--r-- 904 bytes parent folder | download | duplicates (2)
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
# -*- 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.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
conn.bind{
  conn.perror("bind")
  if( defined?(LDAP::LDAP_OPT_HOST_NAME) &&
      defined?(LDAP::LDAP_OPT_PROTOCOL_VERSION) &&
      defined?(LDAP::LDAP_OPT_API_INFO) ) # checking for LDAPv3 API
    host = conn.get_option(LDAP::LDAP_OPT_HOST_NAME)
    proto = conn.get_option(LDAP::LDAP_OPT_PROTOCOL_VERSION)
    begin
      info = conn.get_option(LDAP::LDAP_OPT_API_INFO)
    rescue LDAP::Error
      info = nil
    end
    print("host = #{host}, proto = #{proto}\n",
          "info.protocol_version = #{info.protocol_version}\n")
  end
}

begin
  conn.bind
rescue LDAP::InvalidDataError
  $ok = true
end
if( ! $ok )
  raise(RuntimeError, "multiple bind calls")
end