Skip to content

Commit 935facf

Browse files
committed
Update to include return values
1 parent 03f3eec commit 935facf

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

modules/auxiliary/admin/ldap/ad_cs_cert_template.rb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ def run
116116
end
117117
@ldap = ldap
118118

119-
send("action_#{action.name.downcase}")
119+
result = send("action_#{action.name.downcase}")
120120
print_good('The operation completed successfully!')
121+
result
121122
end
122123
rescue Errno::ECONNRESET
123124
fail_with(Failure::Disconnected, 'The connection was reset.')
@@ -147,7 +148,7 @@ def get_certificate_template
147148
"#{datastore['CERT_TEMPLATE']} Certificate Template"
148149
)
149150
print_status("Certificate template data written to: #{stored}")
150-
obj
151+
[obj, stored]
151152
end
152153

153154
def get_domain_sid
@@ -323,17 +324,19 @@ def action_create
323324
print_status("Creating: #{dn}")
324325
@ldap.add(dn: dn, attributes: attributes)
325326
validate_query_result!(@ldap.get_operation_result.table)
327+
dn
326328
end
327329

328330
def action_delete
329-
obj = get_certificate_template
331+
obj, = get_certificate_template
330332

331333
@ldap.delete(dn: obj['dn'].first)
332334
validate_query_result!(@ldap.get_operation_result.table)
335+
true
333336
end
334337

335338
def action_read
336-
obj = get_certificate_template
339+
obj, stored = get_certificate_template
337340

338341
print_status('Certificate Template:')
339342
print_status(" distinguishedName: #{obj['distinguishedname'].first}")
@@ -477,10 +480,12 @@ def action_read
477480
if obj['pkimaxissuingdepth'].present?
478481
print_status(" pKIMaxIssuingDepth: #{obj['pkimaxissuingdepth'].first.to_i}")
479482
end
483+
484+
{ object: obj, file: stored }
480485
end
481486

482487
def action_update
483-
obj = get_certificate_template
488+
obj, = get_certificate_template
484489
new_configuration = load_local_template
485490

486491
operations = []
@@ -492,6 +497,8 @@ def action_update
492497
unless value.tally == new_value.tally
493498
operations << [:replace, attribute, new_value]
494499
end
500+
elsif attribute == 'ntsecuritydescriptor'
501+
# the security descriptor can't be deleted so leave it alone unless specified
495502
else
496503
operations << [:delete, attribute, nil]
497504
end
@@ -506,10 +513,11 @@ def action_update
506513

507514
if operations.empty?
508515
print_good('There are no changes to be made.')
509-
return
516+
return true
510517
end
511518

512519
@ldap.modify(dn: obj['dn'].first, operations: operations, controls: [ms_security_descriptor_control(DACL_SECURITY_INFORMATION)])
513520
validate_query_result!(@ldap.get_operation_result.table)
521+
true
514522
end
515523
end

0 commit comments

Comments
 (0)