Class: LDAP::Conn

Inherits:
Object
  • Object
show all
Defined in:
lib/active_ldap/adapter/ldap_ext.rb

Instance Method Summary collapse

Instance Method Details

#assert_error_codeObject

Raises:

  • (klass)


119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/active_ldap/adapter/ldap_ext.rb', line 119

def assert_error_code
  return unless failed?
  code = error_code
  message = error_message
  klass = ActiveLdap::LdapError::ERRORS[code]
  klass ||= IMPLEMENT_SPECIFIC_ERRORS[code]
  if klass.nil? and message == "Can't contact LDAP server"
    klass = ActiveLdap::ConnectionError
  end
  klass ||= ActiveLdap::LdapError
  raise klass, message
end

#error_codeObject



105
106
107
108
109
# File 'lib/active_ldap/adapter/ldap_ext.rb', line 105

def error_code
  code = err
  code = get_option(LDAP_OPT_ERROR_NUMBER) if code.zero?
  code
end

#error_messageObject



111
112
113
114
115
116
117
# File 'lib/active_ldap/adapter/ldap_ext.rb', line 111

def error_message
  if failed?
    LDAP.err2string(error_code)
  else
    nil
  end
end

#failed?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/active_ldap/adapter/ldap_ext.rb', line 101

def failed?
  not error_code.zero?
end

#search_full(options, &block) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/active_ldap/adapter/ldap_ext.rb', line 61

def search_full(options, &block)
  base              = options[:base]
  scope             = options[:scope]
  filter            = options[:filter]
  attributes        = options[:attributes]
  limit             = options[:limit] || 0
  use_paged_results = options[:use_paged_results]
  page_size         = options[:page_size]
  if @@have_search_ext
    if use_paged_results
      paged_search(base,
                   scope,
                   filter,
                   attributes,
                   limit,
                   page_size,
                   &block)
    else
      search_ext(base,
                 scope,
                 filter,
                 attributes,
                 false,
                 nil,
                 nil,
                 0,
                 0,
                 limit,
                 &block)
    end
  else
    i = 0
    search(base, scope, filter, attributes) do |entry|
      i += 1
      block.call(entry)
      break if 0 < limit and limit <= i
    end
  end
end