@@ -116,8 +116,9 @@ def run
116
116
end
117
117
@ldap = ldap
118
118
119
- send ( "action_#{ action . name . downcase } " )
119
+ result = send ( "action_#{ action . name . downcase } " )
120
120
print_good ( 'The operation completed successfully!' )
121
+ result
121
122
end
122
123
rescue Errno ::ECONNRESET
123
124
fail_with ( Failure ::Disconnected , 'The connection was reset.' )
@@ -147,7 +148,7 @@ def get_certificate_template
147
148
"#{ datastore [ 'CERT_TEMPLATE' ] } Certificate Template"
148
149
)
149
150
print_status ( "Certificate template data written to: #{ stored } " )
150
- obj
151
+ [ obj , stored ]
151
152
end
152
153
153
154
def get_domain_sid
@@ -323,17 +324,19 @@ def action_create
323
324
print_status ( "Creating: #{ dn } " )
324
325
@ldap . add ( dn : dn , attributes : attributes )
325
326
validate_query_result! ( @ldap . get_operation_result . table )
327
+ dn
326
328
end
327
329
328
330
def action_delete
329
- obj = get_certificate_template
331
+ obj , = get_certificate_template
330
332
331
333
@ldap . delete ( dn : obj [ 'dn' ] . first )
332
334
validate_query_result! ( @ldap . get_operation_result . table )
335
+ true
333
336
end
334
337
335
338
def action_read
336
- obj = get_certificate_template
339
+ obj , stored = get_certificate_template
337
340
338
341
print_status ( 'Certificate Template:' )
339
342
print_status ( " distinguishedName: #{ obj [ 'distinguishedname' ] . first } " )
@@ -477,10 +480,12 @@ def action_read
477
480
if obj [ 'pkimaxissuingdepth' ] . present?
478
481
print_status ( " pKIMaxIssuingDepth: #{ obj [ 'pkimaxissuingdepth' ] . first . to_i } " )
479
482
end
483
+
484
+ { object : obj , file : stored }
480
485
end
481
486
482
487
def action_update
483
- obj = get_certificate_template
488
+ obj , = get_certificate_template
484
489
new_configuration = load_local_template
485
490
486
491
operations = [ ]
@@ -492,6 +497,8 @@ def action_update
492
497
unless value . tally == new_value . tally
493
498
operations << [ :replace , attribute , new_value ]
494
499
end
500
+ elsif attribute == 'ntsecuritydescriptor'
501
+ # the security descriptor can't be deleted so leave it alone unless specified
495
502
else
496
503
operations << [ :delete , attribute , nil ]
497
504
end
@@ -506,10 +513,11 @@ def action_update
506
513
507
514
if operations . empty?
508
515
print_good ( 'There are no changes to be made.' )
509
- return
516
+ return true
510
517
end
511
518
512
519
@ldap . modify ( dn : obj [ 'dn' ] . first , operations : operations , controls : [ ms_security_descriptor_control ( DACL_SECURITY_INFORMATION ) ] )
513
520
validate_query_result! ( @ldap . get_operation_result . table )
521
+ true
514
522
end
515
523
end
0 commit comments