socialcast_ldap_integration 1.1.13 → 1.1.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Socialcast
2
2
  module LdapIntegration
3
- VERSION = "1.1.13"
3
+ VERSION = "1.1.14"
4
4
  end
5
5
  end
@@ -140,6 +140,11 @@ module Socialcast
140
140
  host = connection['host']
141
141
  port = connection['port']
142
142
  map = connection['map']
143
+
144
+ if base.blank?
145
+ base = self.discover_base_dn(map[identifying_field], identifier)
146
+ end
147
+
143
148
  connection_options.reverse_merge!({
144
149
  :host => host,
145
150
  :port => port,
@@ -151,6 +156,17 @@ module Socialcast
151
156
  end
152
157
  return false
153
158
  end
159
+
160
+ # Identifying field will be something like "mail" or "sAMAccountName"
161
+ def self.discover_base_dn(identifying_field, identifier)
162
+ sanitized_field_name = identifying_field.downcase.to_sym
163
+ Socialcast::LdapIntegration.search do |entry, connection|
164
+ if entry.respond_to?(sanitized_field_name) && entry.send(sanitized_field_name).first == identifier
165
+ return entry.dn
166
+ end
167
+ end
168
+ ""
169
+ end
154
170
 
155
171
  # Returns true if LDAP will manage the user field with the given name
156
172
  def self.mirroring_field?(field)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialcast_ldap_integration
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.13
4
+ version: 1.1.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-09-07 00:00:00.000000000 Z
14
+ date: 2012-09-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: socialcast-net-ldap