ldap_query 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.fasterer +29 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +32 -0
- data/.simplecov +18 -0
- data/.yardopts +2 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +27 -0
- data/Gemfile.lock +146 -0
- data/Guardfile +37 -0
- data/LICENSE +21 -0
- data/README.md +116 -0
- data/Rakefile +16 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/ldap_query.gemspec +34 -0
- data/lib/ldap_query.rb +16 -0
- data/lib/ldap_query/authenticate.rb +61 -0
- data/lib/ldap_query/config.rb +126 -0
- data/lib/ldap_query/connection.rb +68 -0
- data/lib/ldap_query/error.rb +11 -0
- data/lib/ldap_query/filter.rb +69 -0
- data/lib/ldap_query/ldap_helper.rb +93 -0
- data/lib/ldap_query/ldap_query.rb +23 -0
- data/lib/ldap_query/query.rb +71 -0
- data/lib/ldap_query/rails_credentials.rb +27 -0
- data/lib/ldap_query/railtie.rb +28 -0
- data/lib/ldap_query/version.rb +5 -0
- data/spec/ldap_lookup/authenticate_spec.rb +9 -0
- data/spec/ldap_lookup/config_spec.rb +24 -0
- data/spec/ldap_lookup/connection_spec.rb +15 -0
- data/spec/ldap_lookup/filter_spec.rb +23 -0
- data/spec/ldap_lookup/query_spec.rb +18 -0
- data/spec/ldap_lookup/rails_credentials_spec.rb +10 -0
- data/spec/spec_helper.rb +106 -0
- data/spec/support/simplecov.rb +5 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 15fdee19f9b94af11b483add2b3c27468e3980fea6cd7a1ba6611b3fd95b88ce
|
4
|
+
data.tar.gz: fdefc85f213d76dabd33933367ddca893d561a5d619399f5375d13800eaa1107
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f6aea9054c415c64aa37c81b623cf8559f9bc1045746a1f913512860b5a236c84b8c8e0051df154b60fb7b73011fb65a7a7a1b85ef66bca7eac277ffb9cfc73a
|
7
|
+
data.tar.gz: 0d52e170bfec76048141366864d9e02ec97472cb062b90054c3d989ad1efb9cb3fe5e02fd0f2b08fc635cb36ddad8d6317d53f89c9bec7d2e182b4151cb2513b
|
data/.fasterer
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
speedups:
|
2
|
+
rescue_vs_respond_to: true
|
3
|
+
module_eval: true
|
4
|
+
shuffle_first_vs_sample: true
|
5
|
+
for_loop_vs_each: true
|
6
|
+
each_with_index_vs_while: false
|
7
|
+
map_flatten_vs_flat_map: true
|
8
|
+
reverse_each_vs_reverse_each: true
|
9
|
+
select_first_vs_detect: true
|
10
|
+
sort_vs_sort_by: true
|
11
|
+
fetch_with_argument_vs_block: true
|
12
|
+
keys_each_vs_each_key: true
|
13
|
+
hash_merge_bang_vs_hash_brackets: true
|
14
|
+
block_vs_symbol_to_proc: true
|
15
|
+
proc_call_vs_yield: true
|
16
|
+
gsub_vs_tr: true
|
17
|
+
select_last_vs_reverse_detect: true
|
18
|
+
getter_vs_attr_reader: true
|
19
|
+
setter_vs_attr_writer: true
|
20
|
+
|
21
|
+
exclude_paths:
|
22
|
+
- '.**'
|
23
|
+
- 'bin/'
|
24
|
+
- 'coverage/'
|
25
|
+
- 'docs/'
|
26
|
+
- 'lib/generators/auth/migration/templates/**'
|
27
|
+
- 'tmp/**/**'
|
28
|
+
- '**.yml'
|
29
|
+
- '**.md'
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
NewCops: disable
|
6
|
+
SuggestExtensions: false
|
7
|
+
Exclude:
|
8
|
+
- Gemfile
|
9
|
+
- Guardfile
|
10
|
+
- Rakefile
|
11
|
+
- '.**'
|
12
|
+
- '**.gemspec'
|
13
|
+
- 'bin/**/*'
|
14
|
+
- 'config/**/*'
|
15
|
+
- 'test/**/*'
|
16
|
+
- 'spec/**/*'
|
17
|
+
- 'vendor/**/*'
|
18
|
+
- '**/**.bak'
|
19
|
+
- '**/**.yml'
|
20
|
+
TargetRubyVersion: 2.6
|
21
|
+
UseCache: true
|
22
|
+
|
23
|
+
Layout/EmptyLineBetweenDefs:
|
24
|
+
Enabled: false
|
25
|
+
Layout/LineLength:
|
26
|
+
Max: 160
|
27
|
+
Metrics/AbcSize:
|
28
|
+
Enabled: false
|
29
|
+
Metrics/MethodLength:
|
30
|
+
Max: 30
|
31
|
+
Naming/MemoizedInstanceVariableName:
|
32
|
+
Enabled: false
|
data/.simplecov
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'simplecov'
|
4
|
+
require 'simplecov-tailwindcss'
|
5
|
+
|
6
|
+
SimpleCov.start do
|
7
|
+
add_filter('/bin/')
|
8
|
+
add_filter('/cache/')
|
9
|
+
add_filter('/docs/')
|
10
|
+
add_filter('/lib/ldap_query/version.rb')
|
11
|
+
add_filter('/spec/support/')
|
12
|
+
end
|
13
|
+
SimpleCov.minimum_coverage(75)
|
14
|
+
SimpleCov.use_merging(false)
|
15
|
+
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
|
16
|
+
SimpleCov::Formatter::HTMLFormatter,
|
17
|
+
SimpleCov::Formatter::TailwindFormatter
|
18
|
+
])
|
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [0.0.1] - 2021-02-28
|
9
|
+
|
10
|
+
- Initial release
|
data/Gemfile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in sailpoint.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
group :development do
|
9
|
+
gem 'guard'
|
10
|
+
gem 'guard-rspec' # Runs tests against your application if spec files are changed
|
11
|
+
gem 'guard-bundler' # Runs bundle install if anything you Gemfile is changed
|
12
|
+
gem 'guard-rubocop' # Runs rubocop tests against your code as files are changed
|
13
|
+
gem 'guard-yard' # Used for generating new yard documentation as changes are made
|
14
|
+
|
15
|
+
gem 'rubocop', require: false
|
16
|
+
gem 'rubocop-performance'
|
17
|
+
gem 'rubocop-rspec'
|
18
|
+
end
|
19
|
+
|
20
|
+
group :test do
|
21
|
+
gem 'fuubar'
|
22
|
+
gem 'rspec'
|
23
|
+
gem 'simplecov', require: false
|
24
|
+
gem 'simplecov-tailwindcss', require: false
|
25
|
+
end
|
26
|
+
|
27
|
+
gem 'pry', group: %i[development test]
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ldap_query (0.0.1)
|
5
|
+
activesupport (>= 5.0)
|
6
|
+
net-ldap (~> 0.16)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (6.1.3)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
zeitwerk (~> 2.3)
|
17
|
+
ast (2.4.2)
|
18
|
+
coderay (1.1.3)
|
19
|
+
concurrent-ruby (1.1.8)
|
20
|
+
diff-lcs (1.4.4)
|
21
|
+
docile (1.3.5)
|
22
|
+
ffi (1.14.2)
|
23
|
+
formatador (0.2.5)
|
24
|
+
fuubar (2.5.1)
|
25
|
+
rspec-core (~> 3.0)
|
26
|
+
ruby-progressbar (~> 1.4)
|
27
|
+
guard (2.16.2)
|
28
|
+
formatador (>= 0.2.4)
|
29
|
+
listen (>= 2.7, < 4.0)
|
30
|
+
lumberjack (>= 1.0.12, < 2.0)
|
31
|
+
nenv (~> 0.1)
|
32
|
+
notiffany (~> 0.0)
|
33
|
+
pry (>= 0.9.12)
|
34
|
+
shellany (~> 0.0)
|
35
|
+
thor (>= 0.18.1)
|
36
|
+
guard-bundler (3.0.0)
|
37
|
+
bundler (>= 2.1, < 3)
|
38
|
+
guard (~> 2.2)
|
39
|
+
guard-compat (~> 1.1)
|
40
|
+
guard-compat (1.2.1)
|
41
|
+
guard-rspec (4.7.3)
|
42
|
+
guard (~> 2.1)
|
43
|
+
guard-compat (~> 1.1)
|
44
|
+
rspec (>= 2.99.0, < 4.0)
|
45
|
+
guard-rubocop (1.4.0)
|
46
|
+
guard (~> 2.0)
|
47
|
+
rubocop (< 2.0)
|
48
|
+
guard-yard (2.2.1)
|
49
|
+
guard (>= 1.1.0)
|
50
|
+
yard (>= 0.7.0)
|
51
|
+
i18n (1.8.9)
|
52
|
+
concurrent-ruby (~> 1.0)
|
53
|
+
listen (3.4.1)
|
54
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
55
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
56
|
+
lumberjack (1.2.8)
|
57
|
+
method_source (1.0.0)
|
58
|
+
minitest (5.14.4)
|
59
|
+
nenv (0.3.0)
|
60
|
+
net-ldap (0.17.0)
|
61
|
+
notiffany (0.1.3)
|
62
|
+
nenv (~> 0.1)
|
63
|
+
shellany (~> 0.0)
|
64
|
+
parallel (1.20.1)
|
65
|
+
parser (3.0.0.0)
|
66
|
+
ast (~> 2.4.1)
|
67
|
+
pry (0.14.0)
|
68
|
+
coderay (~> 1.1)
|
69
|
+
method_source (~> 1.0)
|
70
|
+
rainbow (3.0.0)
|
71
|
+
rake (13.0.3)
|
72
|
+
rb-fsevent (0.10.4)
|
73
|
+
rb-inotify (0.10.1)
|
74
|
+
ffi (~> 1.0)
|
75
|
+
regexp_parser (2.0.3)
|
76
|
+
rexml (3.2.4)
|
77
|
+
rspec (3.10.0)
|
78
|
+
rspec-core (~> 3.10.0)
|
79
|
+
rspec-expectations (~> 3.10.0)
|
80
|
+
rspec-mocks (~> 3.10.0)
|
81
|
+
rspec-core (3.10.1)
|
82
|
+
rspec-support (~> 3.10.0)
|
83
|
+
rspec-expectations (3.10.1)
|
84
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
85
|
+
rspec-support (~> 3.10.0)
|
86
|
+
rspec-mocks (3.10.2)
|
87
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
88
|
+
rspec-support (~> 3.10.0)
|
89
|
+
rspec-support (3.10.2)
|
90
|
+
rubocop (1.9.1)
|
91
|
+
parallel (~> 1.10)
|
92
|
+
parser (>= 3.0.0.0)
|
93
|
+
rainbow (>= 2.2.2, < 4.0)
|
94
|
+
regexp_parser (>= 1.8, < 3.0)
|
95
|
+
rexml
|
96
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
97
|
+
ruby-progressbar (~> 1.7)
|
98
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
99
|
+
rubocop-ast (1.4.1)
|
100
|
+
parser (>= 2.7.1.5)
|
101
|
+
rubocop-performance (1.9.2)
|
102
|
+
rubocop (>= 0.90.0, < 2.0)
|
103
|
+
rubocop-ast (>= 0.4.0)
|
104
|
+
rubocop-rspec (2.2.0)
|
105
|
+
rubocop (~> 1.0)
|
106
|
+
rubocop-ast (>= 1.1.0)
|
107
|
+
ruby-progressbar (1.11.0)
|
108
|
+
shellany (0.0.1)
|
109
|
+
simplecov (0.21.2)
|
110
|
+
docile (~> 1.1)
|
111
|
+
simplecov-html (~> 0.11)
|
112
|
+
simplecov_json_formatter (~> 0.1)
|
113
|
+
simplecov-html (0.12.3)
|
114
|
+
simplecov-tailwindcss (1.0.2)
|
115
|
+
simplecov (~> 0.16)
|
116
|
+
simplecov_json_formatter (0.1.2)
|
117
|
+
thor (1.1.0)
|
118
|
+
tzinfo (2.0.4)
|
119
|
+
concurrent-ruby (~> 1.0)
|
120
|
+
unicode-display_width (2.0.0)
|
121
|
+
yard (0.9.26)
|
122
|
+
zeitwerk (2.4.2)
|
123
|
+
|
124
|
+
PLATFORMS
|
125
|
+
x86_64-darwin-20
|
126
|
+
|
127
|
+
DEPENDENCIES
|
128
|
+
bundler (>= 1.17, < 3.0)
|
129
|
+
fuubar
|
130
|
+
guard
|
131
|
+
guard-bundler
|
132
|
+
guard-rspec
|
133
|
+
guard-rubocop
|
134
|
+
guard-yard
|
135
|
+
ldap_query!
|
136
|
+
pry
|
137
|
+
rake (~> 13)
|
138
|
+
rspec
|
139
|
+
rubocop
|
140
|
+
rubocop-performance
|
141
|
+
rubocop-rspec
|
142
|
+
simplecov
|
143
|
+
simplecov-tailwindcss
|
144
|
+
|
145
|
+
BUNDLED WITH
|
146
|
+
2.2.11
|
data/Guardfile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
rspec_options = {
|
4
|
+
version: 1,
|
5
|
+
all_after_pass: false,
|
6
|
+
all_on_start: false
|
7
|
+
}.freeze
|
8
|
+
|
9
|
+
guard :rspec, cmd: 'rspec' do
|
10
|
+
watch(%r{^spec/.+_spec\.rb$})
|
11
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
12
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
13
|
+
end
|
14
|
+
|
15
|
+
guard :bundler do
|
16
|
+
require 'guard/bundler'
|
17
|
+
require 'guard/bundler/verify'
|
18
|
+
helper = Guard::Bundler::Verify.new
|
19
|
+
|
20
|
+
files = ['Gemfile']
|
21
|
+
files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
|
22
|
+
|
23
|
+
# Assume files are symlinked from somewhere
|
24
|
+
files.each { |file| watch(helper.real_path(file)) }
|
25
|
+
end
|
26
|
+
|
27
|
+
# guard :rubocop do
|
28
|
+
# guard :rubocop, cli: %w(--format fuubar --format html -o ./tmp/rubocop_results.html), launchy: './tmp/rubocop_results.html' do
|
29
|
+
guard :rubocop, cli: %w(--format fuubar) do
|
30
|
+
watch(%r{.+\.rb$})
|
31
|
+
watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
|
32
|
+
end
|
33
|
+
|
34
|
+
# Generates new Yard documentation as the files are changed
|
35
|
+
guard 'yard' do
|
36
|
+
watch(%r{lib\/.+\.rb})
|
37
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Brandon Hicks
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
[![LdapQuery][rubygems-downloads]][rubygems-link]
|
2
|
+
[![Gem Version][rubygems-version]][rubygems-link]
|
3
|
+
[![MIT License][license-shield]][license-url]
|
4
|
+
|
5
|
+
# LdapQuery
|
6
|
+
|
7
|
+
I used to make querying LDAP with a ruby or rails application an easy process rather than pain trying to figure out how to bind the connections. Build a LDAP filter and querying the LDAP host for matching results.
|
8
|
+
|
9
|
+
It was taken into account that not all ruby scripts are part of a rails application, so you can either pass it a credentials hash. But if you're making the queries from a rails application with and haven't passed a credentials hash it resolves to looking for an entry in your encrypted credentials with an ldap key.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'ldap_query'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle install
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install ldap_query
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
If you're using this gems functionality from a rails application you'll want to either add the following to your encrypted credentials file or pass the credentials to your query helpers as an optional parameter.
|
30
|
+
|
31
|
+
```yaml
|
32
|
+
ldap:
|
33
|
+
host: company_host.tld
|
34
|
+
base: DC=company,DC=org,DC=tld
|
35
|
+
username: cn=Common,OU=Organization,DC=Domain,DC=tld
|
36
|
+
password: password123
|
37
|
+
port: 636
|
38
|
+
encryption: simple_tls
|
39
|
+
method: simple
|
40
|
+
```
|
41
|
+
|
42
|
+
_(port, encryption, and method are optional)_
|
43
|
+
|
44
|
+
If using this gem in a rails application there are helpers available that you can called from your controllers, views/helpers, and/or models.
|
45
|
+
|
46
|
+
#### Rails Helpers
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
search_ldap_by_username(str) # seaches for a matching `cn`
|
50
|
+
|
51
|
+
search_ldap_by_name(str) # searches for a matching `displayname`
|
52
|
+
|
53
|
+
search_ldap_by_group(str) # tries to find a match against a matching `memberof`
|
54
|
+
|
55
|
+
search_ldap_by_mail(str) # matches against the ldap users mail attribute
|
56
|
+
|
57
|
+
search_ldap_by_other(attr: 'key', val: 'val') # matches against the specified ldap attribute and value
|
58
|
+
|
59
|
+
authenticate_user(username: 'jdoe', password: 'pass123') # Bind a user against the ldap base to authenticate their credentials
|
60
|
+
```
|
61
|
+
|
62
|
+
There are 2 optional keyword parameters you can pass when using these helpers, `wildcard:` and `limit:`.
|
63
|
+
|
64
|
+
Default values
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
wildcard: false # when set as false it expects an exact match
|
68
|
+
limit: 20 # default limit of ldap results returned
|
69
|
+
```
|
70
|
+
|
71
|
+
Without wildcard ldap requires an exact match like, ie if you have a user with a displayname of `John A. Doe` and you do a lookup with wildcard as false with the str `John Doe` it won't return the user. But if wildcard is set as true it compares against ldap with the value of `John*Doe`. Which _should_ match the user,
|
72
|
+
|
73
|
+
To change these values you just add the key and value to the method call.
|
74
|
+
|
75
|
+
`search_ldap_by_username('jdoe', wildcard: true)`
|
76
|
+
|
77
|
+
|
78
|
+
These helpers also allow a _(optional)_ secondary parameter to be passed to them. This secondary will be used as the ldap credential. By default the gem will pull the ldap connections credentials from your encrypted credentials, so you don't need to pass paramters, if you have set the credentials with a base key of `ldap:`. But the one case were you may need to pass the credentials is if you want to hit multiple ldap hosts/bases to grab different results.
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
first_results = search_ldap_by_username('jdoe', first_host_credentials_hash)
|
82
|
+
second_results = search_ldap_by_username('jdoe', hash_host_credentials_hash)
|
83
|
+
```
|
84
|
+
|
85
|
+
#### CLI or Ruby script
|
86
|
+
|
87
|
+
But these helpers are optional and can be used in CLI or through a ruby script without having to use rails.
|
88
|
+
|
89
|
+
Jsut be sure to include the LdapQuery gem into your ruby script or terminal with the following: `require 'ldap_query'`.
|
90
|
+
|
91
|
+
The main part of build the query if using `LdapQuery::Query.perform` method. You need to ensure you pass the credentials hash, the ldap attribute you want to query againt _(ie: :cn)_ and the val you are will be querying ldap with. As see from the helper methods above you can also pass the keyword/values for `wildcard` and `limit`.
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
require 'ldap_query'
|
95
|
+
|
96
|
+
# You LDAP credentials always need to be passed as hash, listed below are the required parameters
|
97
|
+
# (optional parameters include: port, method, and encryption)
|
98
|
+
credentials = { base: 'DC=company,DC=org,DC=tld', username: 'cn=Common,OU=Organization,DC=Domain,DC=tld', password: 'password123', host: 'company.tld' }
|
99
|
+
|
100
|
+
LdapQuery::Query.perform(credentials, attr: :cn, val: str)
|
101
|
+
LdapQuery::Query.perform(credentials, attr: :displayname, val: 'John Doe', limit: 3)
|
102
|
+
```
|
103
|
+
|
104
|
+
## Contributing
|
105
|
+
|
106
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tarellel/ldap_query.
|
107
|
+
|
108
|
+
## License
|
109
|
+
|
110
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
111
|
+
|
112
|
+
[license-shield]: https://img.shields.io/github/license/tarellel/ldap_query.svg?style=flat-square
|
113
|
+
[license-url]: https://github.com/tarellel/ldap_query/blob/master/LICENSE
|
114
|
+
[rubygems-downloads]: https://ruby-gem-downloads-badge.herokuapp.com/ldap_query?type=total
|
115
|
+
[rubygems-link]: https://rubygems.org/gems/ldap_query
|
116
|
+
[rubygems-version]: https://badge.fury.io/rb/ldap_query.svg
|