Skip to content

Commit 1bf1fb5

Browse files
authored
Merge pull request #4 from timogoebel/ou
specify host ou
2 parents 5e5890a + daaa5fd commit 1bf1fb5

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

config/realm_ad.yml.example

+3
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@
55
:keytab_path: /etc/foreman-proxy/realm_ad.keytab
66
:principal: realm-proxy@EXAMPLE.COM
77

8+
# Optional: OU where the machine account shall be placed
9+
#:ou: OU=Linux,OU=Servers,DC=example,DC=com
10+
811
:domain_controller: dc.example.com

lib/smart_proxy_realm_ad/configuration_loader.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ def load_dependency_injection_wirings(container_instance, settings)
1111
settings[:realm],
1212
settings[:keytab_path],
1313
settings[:principal],
14-
settings[:domain_controller]
14+
settings[:domain_controller],
15+
settings[:ou]
1516
)
1617
}
1718
end
1819
end
19-
end
20+
end

lib/smart_proxy_realm_ad/provider.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ class Provider
88
include Proxy::Util
99
include Proxy::Kerberos
1010

11-
def initialize(realm, keytab_path, principal, domain_controller)
11+
def initialize(realm, keytab_path, principal, domain_controller, ou)
1212
@realm = realm
1313
@keytab_path = keytab_path
1414
@principal = principal
1515
@domain_controller = domain_controller
1616
@domain = realm.downcase
17-
logger.info "Proxy::AdRealm: initialize... #{@realm}, #{@keytab_path}, #{@principal}, #{@domain_controller}, #{@domain}"
17+
@ou = ou
18+
logger.info "Proxy::AdRealm: initialize... #{@realm}, #{@keytab_path}, #{@principal}, #{@domain_controller}, #{@domain}, #{ou}"
1819
end
1920

2021
def check_realm realm
@@ -92,6 +93,7 @@ def radcli_join hostfqdn, hostname, password
9293
enroll = Adcli::AdEnroll.new(@adconn)
9394
enroll.set_computer_name(hostname)
9495
enroll.set_host_fqdn(hostfqdn)
96+
enroll.set_domain_ou(@ou) if @ou
9597
enroll.set_computer_password(password)
9698
enroll.join()
9799
end
@@ -104,6 +106,7 @@ def radcli_password hostname, password
104106
# Reset a computer's password
105107
enroll = Adcli::AdEnroll.new(@adconn)
106108
enroll.set_computer_name(hostname)
109+
enroll.set_domain_ou(@ou) if @ou
107110
enroll.set_computer_password(password)
108111
enroll.password()
109112
end
@@ -112,6 +115,7 @@ def radcli_delete hostname
112115
# Delete a computer's account
113116
enroll = Adcli::AdEnroll.new(@adconn)
114117
enroll.set_computer_name(hostname)
118+
enroll.set_domain_ou(@ou) if @ou
115119
enroll.delete()
116120
end
117121

0 commit comments

Comments
 (0)