@@ -502,6 +502,40 @@ def test_search_net_ldap_connection_event
502
502
assert unread . empty? , "should not have any leftover unread messages"
503
503
end
504
504
505
+ def test_add_with_controls
506
+ dacl_flag = 0x4 # DACL_SECURITY_INFORMATION
507
+ control_values = [ dacl_flag ] . map ( &:to_ber ) . to_ber_sequence . to_s . to_ber
508
+ controls = [ ]
509
+ # LDAP_SERVER_SD_FLAGS constant definition, taken from https://ldapwiki.com/wiki/LDAP_SERVER_SD_FLAGS_OID
510
+ ldap_server_sd_flags = '1.2.840.113556.1.4.801' . freeze
511
+ controls << [ ldap_server_sd_flags . to_ber , true . to_ber , control_values ] . to_ber_sequence
512
+
513
+ ber = Net ::BER ::BerIdentifiedArray . new ( [ Net ::LDAP ::ResultCodeSuccess , "" , "" ] )
514
+ ber . ber_identifier = Net ::LDAP ::PDU ::AddResponse
515
+ @tcp_socket . should_receive ( :read_ber ) . and_return ( [ 1 , ber ] )
516
+
517
+ result = @connection . add ( :dn => "uid=added-user1,ou=People,dc=rubyldap,dc=com" , :controls => controls )
518
+ assert result . success? , "should be success"
519
+ assert_equal "" , result . error_message
520
+ end
521
+
522
+ def test_modify_with_controls
523
+ dacl_flag = 0x4 # DACL_SECURITY_INFORMATION
524
+ control_values = [ dacl_flag ] . map ( &:to_ber ) . to_ber_sequence . to_s . to_ber
525
+ controls = [ ]
526
+ # LDAP_SERVER_SD_FLAGS constant definition, taken from https://ldapwiki.com/wiki/LDAP_SERVER_SD_FLAGS_OID
527
+ ldap_server_sd_flags = '1.2.840.113556.1.4.801' . freeze
528
+ controls << [ ldap_server_sd_flags . to_ber , true . to_ber , control_values ] . to_ber_sequence
529
+
530
+ ber = Net ::BER ::BerIdentifiedArray . new ( [ Net ::LDAP ::ResultCodeSuccess , "" , "" ] )
531
+ ber . ber_identifier = Net ::LDAP ::PDU ::ModifyResponse
532
+ @tcp_socket . should_receive ( :read_ber ) . and_return ( [ 1 , ber ] )
533
+
534
+ result = @connection . modify ( :dn => "1" , :operations => [ [ :replace , "mail" , "[email protected] " ] ] , :controls => controls )
535
+ assert result . success? , "should be success"
536
+ assert_equal "" , result . error_message
537
+ end
538
+
505
539
def test_search_with_controls
506
540
# search data
507
541
search_data_ber = Net ::BER ::BerIdentifiedArray . new ( [ 1 , [
0 commit comments