Class: DCDetector::App
- Inherits:
-
Object
- Object
- DCDetector::App
- Defined in:
- lib/dcdetector.rb
Overview
DCDetector main class
Instance Method Summary collapse
-
#dc_fqdn ⇒ Array
Get DC(s) FQDN.
-
#dc_ip ⇒ Array
Get DC(s) IP address.
-
#dc_name ⇒ Array
Get DC(s) computer name.
-
#initialize(ad_domain, dns_opts = nil) ⇒ App
constructor
Create the DCDetector object.
Constructor Details
#initialize(ad_domain, dns_opts = nil) ⇒ App
Create the DCDetector object.
20 21 22 23 |
# File 'lib/dcdetector.rb', line 20 def initialize(ad_domain, dns_opts = nil) @ad_domain = ad_domain @dns_opts = dns_opts end |
Instance Method Details
#dc_fqdn ⇒ Array
Get DC(s) FQDN
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dcdetector.rb', line 31 def dc_fqdn Resolv::DNS.open(@dns_opts) do |dns| # _kerberos._tcp, _kpasswd._tcp, _ldap._tcp works too but are not MS only # _kerberos._tcp.dc._msdcs # _ldap._tcp.pdc._msdcs, _gc._tcp # _udp variants ress = dns.getresources "_ldap._tcp.dc._msdcs.#{@ad_domain}", Resolv::DNS::Resource::IN::ANY ress.map { |x| x.target.to_s } end end |
#dc_ip ⇒ Array
Get DC(s) IP address
56 57 58 59 60 61 |
# File 'lib/dcdetector.rb', line 56 def dc_ip Resolv::DNS.open(@dns_opts) do |dns| ress = dns.getresources "gc._msdcs.#{@ad_domain}", Resolv::DNS::Resource::IN::A ress.map { |x| x.address.to_s } end end |
#dc_name ⇒ Array
Get DC(s) computer name
47 48 49 |
# File 'lib/dcdetector.rb', line 47 def dc_name dc_fqdn.map { |x| x[...-@ad_domain.size - 1] } end |