Hi,
I know this is all over the internet but I wasn’t able to get the data that I need after doing lots of trial and errors from the solutions that I’ve found online. I need to have it as anonymous bind.
Here is my code. It’s in rubocop format. I cannot get any data of computer01
in allomputers
OU using the ldap.search
. Anything that I’ve been missing?
#!/bin/ruby
require 'net/ldap'
hostname = 'computer01'
domain = 'host.domain'
treebase = 'OU=allcomputers,DC=host,DC=domain'
ldap = Net::LDAP.new host: domain,
port: 636,
base: treebase,
encryption: { method: :simple_tls, tls_options: { verify_mode: OpenSSL::SSL::VERIFY_NONE } } ,
force_no_page: true
filter = Net::LDAP::Filter.eq('CN', hostname)
ldap.search(base: treebase, filter: filter) do |entry|
p entry.dn
# not verifying SSL hostname of LDAPS server 'allcomputer.domain:636'
end
Thank you.