Module: Yast::SambaServerLdapWidgetInclude

Defined in:
../../src/include/samba-server/ldap-widget.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) _try_connect(url, admin_dn, passwd)

Samba LDAP Settings Essential Widget ////////////////////////////////////////////////////////////////////



163
164
165
166
167
168
169
170
171
172
173
174
175
# File '../../src/include/samba-server/ldap-widget.rb', line 163

def _try_connect(url, admin_dn, passwd)
  if url == ""
    # translators: popup warning message about empty text entry
    Popup.Warning(_("Enter the server URL."))
    return false
  end
  err = SambaBackendLDAP.TryBind(url, admin_dn, passwd)
  if err != nil
    Ldap.LDAPErrorMessage("bind", err)
    return false
  end
  true
end

- (Object) CreateSambaLDAPSettingsEssentialWidget



431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
# File '../../src/include/samba-server/ldap-widget.rb', line 431

def CreateSambaLDAPSettingsEssentialWidget
  basedn = VBox(
    # translators: text entry label
    TextEntry(Id("ldap suffix"), _("&Search Base DN"))
  )
  auth = Frame(
    _("Authentication"),
    VBox(
      # translators: text entry label
      TextEntry(Id("ldap admin dn"), _("&Administration DN")),
      # BNC #446794
      HSquash(
        VBox(
          # TODO: if Mode::config() => no ask for pssword
          # translators: password enrty label
          Password(
            Id(:passwd1),
            Opt(:hstretch),
            _("Administration &Password")
          ),
          # translators: reenter password entry label
          Password(
            Id(:passwd2),
            Opt(:hstretch),
            _("Administration Password (A&gain)")
          )
        )
      ),
      ReplacePoint(Id("passwd_label"), Label("")),
      Empty(Opt(:vstretch))
    )
  )
  passdb =
    # translators: frame title (passdb == password database)
    Frame(
      _("Passdb Back-End"),
      VBox(
        # translators: check box label
        Left(
          CheckBox(
            Id(:ldap_passdb_backend_enable),
            Opt(:notify),
            _("Use LDAP Password &Back-End")
          )
        ),
        # translators: text entry label
        TextEntry(Id(:ldap_passdb_backend_url), _("LDAP Server &URL")),
        Empty(Opt(:vstretch))
      )
    )

  idmap =
    # translators: frame title (idmap = user id mapping)
    Frame(
      _("Idmap Back-End"),
      VBox(
        # translators: check box label
        Left(
          CheckBox(
            Id(:ldap_idmap_backend_enable),
            Opt(:notify),
            _("Use LDAP &Idmap Back-End")
          )
        ),
        # translators: text entry label
        TextEntry(Id(:ldap_idmap_backend_url), _("LDAP Server U&RL")),
        Empty(Opt(:vstretch))
      )
    )


  essential_widget = Top(
    HBox(
      HSpacing(1),
      VBox(
        VWeight(1, Empty()),
        VSquash(
          HBox(
            HWeight(1, VBox(passdb, idmap)),
            HSpacing(1),
            HWeight(1, auth)
          )
        ),
        VWeight(1, Empty()),
        basedn,
        VWeight(8, Empty()),
        Right(
          HBox(
            PushButton(Id(:ldap_try_connect), _("&Test Connection")),
            MenuButton(
              Id(:ldap_advanced_settings),
              _("Advanced &Settings..."),
              [
                Item(Id(:ldap_expert_settings), _("Expert LDAP Settings")),
                Item(Id(:ldap_suse_defaults), _("Default Values"))
              ]
            )
          )
        )
      ),
      HSpacing(1)
    )
  )

  {
    "widget"            => :custom,
    "custom_widget"     => essential_widget,
    "init"              => fun_ref(
      method(:SambaLDAPSettingsEssentialWidgetInit),
      "void (string)"
    ),
    "handle"            => fun_ref(
      method(:SambaLDAPSettingsEssentialWidgetHandle),
      "symbol (string, map)"
    ),
    "store"             => fun_ref(
      method(:SambaLDAPSettingsEssentialWidgetStore),
      "void (string, map)"
    ),
    "validate_type"     => :function,
    "validate_function" => fun_ref(
      method(:SambaLDAPSettingsEssentialWidgetValidate),
      "boolean (string, map)"
    ),
    "help"              => Ops.get_string(
      @HELPS,
      "samba_ldap_setting_auth_widget",
      ""
    )
  }
end

- (Object) CreateSambaLDAPSettingsMiscWidget



746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
# File '../../src/include/samba-server/ldap-widget.rb', line 746

def CreateSambaLDAPSettingsMiscWidget
  # translators: frame label
  misc_widget = Frame(
    _("Other Settings"),
    VBox(
      # No such option, bug 169194
      # translators: text entry label
      # `Left(`TextEntry(`id("ldap filter"), _("Search &Filter"))),

      # translators: combo box label
      Left(
        ComboBox(
          Id("ldap delete dn"),
          _("&Delete DN"),
          Builtins.maplist(@ldap_yes_no_values) do |l|
            Item(Id(Ops.get_string(l, 0, "")), Ops.get_string(l, 1, ""))
          end
        )
      ),
      # translators: combo box label
      Left(
        ComboBox(
          Id("ldap passwd sync"),
          _("&Synchronize Passwords"),
          Builtins.maplist(@ldap_yes_no_only_values) do |l|
            Item(Id(Ops.get_string(l, 0, "")), Ops.get_string(l, 1, ""))
          end
        )
      )
    )
  )

  {
    "widget"        => :custom,
    "custom_widget" => misc_widget,
    "init"          => fun_ref(
      method(:SambaLDAPSettingsMiscWidgetInit),
      "void (string)"
    ),
    "store"         => fun_ref(
      method(:SambaLDAPSettingsMiscWidgetStore),
      "void (string, map)"
    ),
    "help"          => Ops.get_string(
      @HELPS,
      "samba_ldap_settings_misc_widget",
      ""
    )
  }
end

- (Object) CreateSambaLDAPSettingsSecurityWidget



692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
# File '../../src/include/samba-server/ldap-widget.rb', line 692

def CreateSambaLDAPSettingsSecurityWidget
  # translators: frame label
  widget = Frame(
    _("Security"),
    VBox(
      # translators: combo box label
      Left(
        ComboBox(
          Id("ldap ssl"),
          _("&Use SSL or TLS"),
          Builtins.maplist(@ldap_ssl_values) do |l|
            Item(Id(Ops.get_string(l, 0, "")), Ops.get_string(l, 1, ""))
          end
        )
      )
    )
  )

  {
    "widget"        => :custom,
    "custom_widget" => widget,
    "init"          => fun_ref(
      method(:SambaLDAPSettingsSecurityWidgetInit),
      "void (string)"
    ),
    "store"         => fun_ref(
      method(:SambaLDAPSettingsSecurityWidgetStore),
      "void (string, map)"
    ),
    "help"          => Ops.get_string(
      @HELPS,
      "samba_ldap_settings_security_widget",
      ""
    )
  }
end

- (Object) CreateSambaLDAPSettingsSuffixesWidget



586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
# File '../../src/include/samba-server/ldap-widget.rb', line 586

def CreateSambaLDAPSettingsSuffixesWidget
  # translators: frame label
  suffixes_widget = Frame(
    _("Suffixes"),
    VBox(
      # translators: text entry label
      Left(TextEntry(Id("ldap user suffix"), _("&User Suffix"))),
      # translators: text entry label
      Left(TextEntry(Id("ldap group suffix"), _("&Group Suffix"))),
      # translators: text entry label
      Left(TextEntry(Id("ldap machine suffix"), _("&Machine Suffix"))),
      # translators: text entry label
      Left(TextEntry(Id("ldap idmap suffix"), _("&Idmap Suffix")))
    )
  )

  {
    "widget"        => :custom,
    "custom_widget" => suffixes_widget,
    "init"          => fun_ref(
      method(:SambaLDAPSettingsSuffixesWidgetInit),
      "void (string)"
    ),
    "store"         => fun_ref(
      method(:SambaLDAPSettingsSuffixesWidgetStore),
      "void (string, map)"
    ),
    "help"          => Ops.get_string(
      @HELPS,
      "samba_ldap_setting_suffixes_widget",
      ""
    )
  }
end

- (Object) CreateSambaLDAPSettingsTimeoutsWidget



640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
# File '../../src/include/samba-server/ldap-widget.rb', line 640

def CreateSambaLDAPSettingsTimeoutsWidget
  # translators: frame label
  timeouts_widget = Frame(
    _("Time-Outs"),
    VBox(
      # translators: integer field label
      Left(
        IntField(
          Id("ldap replication sleep"),
          _("&Replication Sleep"),
          0,
          999999,
          3
        )
      ),
      # translators: integer field label
      Left(IntField(Id("ldap timeout"), _("&Time-Out"), 0, 999999, 3))
    )
  )

  {
    "widget"        => :custom,
    "custom_widget" => timeouts_widget,
    "init"          => fun_ref(
      method(:SambaLDAPSettingsTimeoutsWidgetInit),
      "void (string)"
    ),
    "store"         => fun_ref(
      method(:SambaLDAPSettingsTimeoutsWidgetStore),
      "void (string, map)"
    ),
    "help"          => Ops.get_string(
      @HELPS,
      "samba_ldap_settings_timeouts_widget",
      ""
    )
  }
end

- (Object) init_ldap_combo(id, m)



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File '../../src/include/samba-server/ldap-widget.rb', line 113

def init_ldap_combo(id, m)
  m = deep_copy(m)
  val = Builtins.tolower(
    SambaConfig.GlobalGetStr(id, SambaBackendLDAP.GetSambaDefaultValue(id))
  )
  subid = nil
  Builtins.foreach(
    Convert.convert(m, :from => "list", :to => "list <list>")
  ) do |l|
    if subid == nil
      if Builtins.tolower(Ops.get_string(l, 0, "")) == val
        subid = Ops.get_string(l, 0, "")
      end
    end
  end
  UI.ChangeWidget(Id(id), :Value, subid)

  nil
end

- (Object) init_ldap_int(id)



100
101
102
103
104
105
106
107
108
109
110
111
# File '../../src/include/samba-server/ldap-widget.rb', line 100

def init_ldap_int(id)
  UI.ChangeWidget(
    Id(id),
    :Value,
    SambaConfig.GlobalGetInteger(
      id,
      Builtins.tointeger(SambaBackendLDAP.GetSambaDefaultValue(id))
    )
  )

  nil
end

- (Object) init_ldap_str(id)

helper functions



90
91
92
93
94
95
96
97
98
# File '../../src/include/samba-server/ldap-widget.rb', line 90

def init_ldap_str(id)
  UI.ChangeWidget(
    Id(id),
    :Value,
    SambaConfig.GlobalGetStr(id, SambaBackendLDAP.GetSambaDefaultValue(id))
  )

  nil
end

- (Object) initialize_samba_server_ldap_widget(include_target)



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File '../../src/include/samba-server/ldap-widget.rb', line 37

def initialize_samba_server_ldap_widget(include_target)
  Yast.import "UI"

  textdomain "samba-server"

  Yast.import "URL"
  Yast.import "Popup"

  Yast.import "CWM"
  Yast.import "Ldap"
  Yast.import "Label"
  Yast.import "Wizard"

  Yast.import "SambaConfig"
  Yast.import "SambaBackend"
  Yast.import "SambaBackendLDAP"

  Yast.include include_target, "samba-server/helps.rb"


  @widget_names = nil
  @widget_descr = nil

  # Samba LDAP Settings Security Widget
  #/////////////////////////////////////////////////////////////////////////

  # translators: combo box value
  @ldap_ssl_values = [
    ["Off", _("No")],
    # translators: combo box value
    ["Start_tls", _("TLS")]
  ]


  # Samba LDAP Settings Misc Widget
  #/////////////////////////////////////////////////////////////////////////

  # translators: combo box value
  @ldap_yes_no_values = [
    ["Yes", _("Yes")],
    # translators: combo box value
    ["No", _("No")]
  ]
  # translators: combo box value (updata password? Yes/No/Only = Only update the LDAP password and let the LDAP server do the rest)
  @ldap_yes_no_only_values = Convert.convert(
    Builtins.merge(@ldap_yes_no_values, [["Only", _("Only")]]),
    :from => "list",
    :to   => "list <list>"
  )
end

- (Object) ProposeDefaultValues



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File '../../src/include/samba-server/ldap-widget.rb', line 260

def ProposeDefaultValues
  SambaConfig.GlobalSetMap(SambaBackendLDAP.GetSuseDefaultValues)
  if Ldap.server != nil && Ldap.server != ""
    SambaConfig.GlobalSetStr(
      "idmap backend",
      Ops.add("ldap:ldap://", Ldap.GetFirstServer(Ldap.server))
    )
    SambaBackend.AddPassdbBackend(
      "ldapsam",
      Ops.add("ldap://", Ldap.GetFirstServer(Ldap.server))
    )
  else
    SambaConfig.GlobalSetStr("idmap backend", nil)
    SambaBackend.RemovePassdbBackend("ldapsam")
  end
  SambaLDAPSettingsEssentialWidgetInit(nil)

  nil
end

- (Object) SambaLDAPExpertSettingsDialog



796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
# File '../../src/include/samba-server/ldap-widget.rb', line 796

def SambaLDAPExpertSettingsDialog
  widget_descr = {
    "SUFFIXES" => CreateSambaLDAPSettingsSuffixesWidget(),
    "TIMEOUTS" => CreateSambaLDAPSettingsTimeoutsWidget(),
    "SECURITY" => CreateSambaLDAPSettingsSecurityWidget(),
    "MISC"     => CreateSambaLDAPSettingsMiscWidget()
  }

  contents = VBox(
    HBox(
      HSpacing(1),
      HWeight(1, VBox("SECURITY", "SUFFIXES", Empty(Opt(:vstretch)))),
      HSpacing(1),
      HWeight(1, VBox("TIMEOUTS", "MISC", Empty(Opt(:vstretch)))),
      HSpacing(1)
    ),
    VStretch()
  )

  Wizard.CreateDialog
  ret = CWM.ShowAndRun(
    {
      "widget_names" => ["SUFFIXES", "TIMEOUTS", "SECURITY", "MISC"],
      "widget_descr" => widget_descr,
      "contents"     => contents,
      # translators: dialog caption
      "caption"      => _(
        "Expert LDAP Settings"
      ),
      "back_button"  => Label.CancelButton,
      "next_button"  => Label.OKButton,
      "abort_button" => nil
    }
  )
  UI.CloseDialog

  ret
end

- (Object) SambaLDAPSettingsEssentialWidgetHandle(key, event_descr)



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# File '../../src/include/samba-server/ldap-widget.rb', line 280

def SambaLDAPSettingsEssentialWidgetHandle(key, event_descr)
  event_descr = deep_copy(event_descr)
  id = Ops.get(event_descr, "ID")

  if id == :passwd1 || id == :passwd2
    passwd1 = Convert.to_string(UI.QueryWidget(Id(:passwd1), :Value))
    passwd2 = Convert.to_string(UI.QueryWidget(Id(:passwd2), :Value))
    if passwd1 != passwd2
      # translators: inform text
      UI.ReplaceWidget(
        Id("passwd_label"),
        Left(Label(_("Passwords do not match.")))
      )
      UI.ChangeWidget(Id(:ldap_try_connect), :Enabled, false)
      UI.SetFocus(Id(:passwd2))
    elsif passwd1 == SambaBackendLDAP.GetAdminPassword
      UI.ReplaceWidget(Id("passwd_label"), Left(Label("")))
      UI.ChangeWidget(Id(:ldap_try_connect), :Enabled, true)
    else
      # translators: inform text
      UI.ReplaceWidget(
        Id("passwd_label"),
        Left(Label(_("Passwords match.")))
      )
      UI.ChangeWidget(Id(:ldap_try_connect), :Enabled, true)
    end
  elsif id == :ldap_passdb_backend_enable ||
      id == :ldap_idmap_backend_enable
    passdb = Convert.to_boolean(
      UI.QueryWidget(Id(:ldap_passdb_backend_enable), :Value)
    )
    UI.ChangeWidget(Id(:ldap_passdb_backend_url), :Enabled, passdb)

    idmap = Convert.to_boolean(
      UI.QueryWidget(Id(:ldap_idmap_backend_enable), :Value)
    )
    UI.ChangeWidget(Id(:ldap_idmap_backend_url), :Enabled, idmap)

    Builtins.foreach(
      [
        "ldap suffix",
        "ldap admin dn",
        :passwd1,
        :passwd2,
        :ldap_try_connect,
        :ldap_advanced_settings
      ]
    ) { |id2| UI.ChangeWidget(Id(id2), :Enabled, idmap || passdb) }

    # Propose default values
    if passdb || idmap
      some_values_filled = false
      Builtins.foreach(
        [
          :passwd1,
          :passwd2,
          :ldap_passdb_backend_url,
          :ldap_passdb_backend_url,
          :ldap_idmap_backend_url,
          :ldap_idmap_backend_url
        ]
      ) do |ui_widget_setting|
        read_value = Convert.to_string(
          UI.QueryWidget(Id(ui_widget_setting), :Value)
        )
        if read_value != "" && read_value != nil
          some_values_filled = true
          raise Break
        end
      end

      if some_values_filled == false &&
          Popup.YesNo(
            _(
              "All current LDAP-related values will be rewritten.\nContinue?\n"
            )
          )
        Builtins.y2milestone("Proposing default values...")
        ProposeDefaultValues()
      end
    end
  elsif id == :ldap_expert_settings
    SambaLDAPExpertSettingsDialog()
  elsif id == :ldap_try_connect
    if SambaLDAPTryConnect()
      # translators: popup message
      Popup.Message(_("Connection successful."))
    end
  elsif id == :ldap_suse_defaults
    # translators: popup message
    if Popup.YesNo(
        _("All current LDAP-related values will be rewritten.\nContinue?\n")
      )
      ProposeDefaultValues()
    end
  end

  nil
end

- (Object) SambaLDAPSettingsEssentialWidgetInit(key)



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File '../../src/include/samba-server/ldap-widget.rb', line 213

def SambaLDAPSettingsEssentialWidgetInit(key)
  init_ldap_str("ldap suffix")

  init_ldap_str("ldap admin dn")
  UI.ChangeWidget(Id(:passwd1), :Value, SambaBackendLDAP.GetAdminPassword)
  UI.ChangeWidget(Id(:passwd2), :Value, SambaBackendLDAP.GetAdminPassword)

  passdb_url = SambaBackendLDAP.GetPassdbServerUrl
  UI.ChangeWidget(
    Id(:ldap_passdb_backend_url),
    :Value,
    passdb_url == nil ? "" : URL.Build(passdb_url)
  )
  UI.ChangeWidget(Id(:ldap_passdb_backend_url), :Enabled, passdb_url != nil)
  UI.ChangeWidget(
    Id(:ldap_passdb_backend_enable),
    :Value,
    passdb_url != nil
  )

  idmap_url = SambaBackendLDAP.GetIdmapServerUrl
  UI.ChangeWidget(
    Id(:ldap_idmap_backend_url),
    :Value,
    idmap_url == nil ? "" : URL.Build(idmap_url)
  )
  UI.ChangeWidget(Id(:ldap_idmap_backend_url), :Enabled, idmap_url != nil)
  UI.ChangeWidget(Id(:ldap_idmap_backend_enable), :Value, idmap_url != nil)

  Builtins.foreach(
    [
      "ldap suffix",
      "ldap admin dn",
      :passwd1,
      :passwd2,
      :ldap_try_connect,
      :ldap_advanced_settings
    ]
  ) do |id|
    UI.ChangeWidget(Id(id), :Enabled, idmap_url != nil || passdb_url != nil)
  end

  UI.SetFocus(Id(:passwd1))

  nil
end

- (Object) SambaLDAPSettingsEssentialWidgetStore(key, event_descr)



395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# File '../../src/include/samba-server/ldap-widget.rb', line 395

def SambaLDAPSettingsEssentialWidgetStore(key, event_descr)
  event_descr = deep_copy(event_descr)
  store_ldap_str("ldap admin dn")
  store_ldap_str("ldap suffix")

  passwd = Convert.to_string(UI.QueryWidget(Id(:passwd1), :Value))
  SambaBackendLDAP.SetAdminPassword(passwd)

  passdb = Convert.to_boolean(
    UI.QueryWidget(Id(:ldap_passdb_backend_enable), :Value)
  )
  idmap = Convert.to_boolean(
    UI.QueryWidget(Id(:ldap_idmap_backend_enable), :Value)
  )

  if passdb
    passdb_url = Convert.to_string(
      UI.QueryWidget(Id(:ldap_passdb_backend_url), :Value)
    )
    SambaBackend.AddPassdbBackend("ldapsam", passdb_url)
  else
    SambaBackend.RemovePassdbBackend("ldapsam")
  end

  if idmap
    idmap_url = Convert.to_string(
      UI.QueryWidget(Id(:ldap_idmap_backend_url), :Value)
    )
    SambaConfig.GlobalSetStr("idmap backend", Ops.add("ldap:", idmap_url))
  else
    SambaConfig.GlobalSetStr("idmap backend", nil)
  end

  nil
end

- (Object) SambaLDAPSettingsEssentialWidgetValidate(key, event)



380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File '../../src/include/samba-server/ldap-widget.rb', line 380

def SambaLDAPSettingsEssentialWidgetValidate(key, event)
  event = deep_copy(event)
  passdb = Convert.to_boolean(
    UI.QueryWidget(Id(:ldap_passdb_backend_enable), :Value)
  )
  idmap = Convert.to_boolean(
    UI.QueryWidget(Id(:ldap_idmap_backend_enable), :Value)
  )
  return true if !passdb && !idmap

  return false if !SambaLDAPTryConnect()

  true
end

- (Object) SambaLDAPSettingsMiscWidgetInit(key)



729
730
731
732
733
734
735
# File '../../src/include/samba-server/ldap-widget.rb', line 729

def SambaLDAPSettingsMiscWidgetInit(key)
  # init_ldap_str("ldap filter");
  init_ldap_combo("ldap delete dn", @ldap_yes_no_values)
  init_ldap_combo("ldap passwd sync", @ldap_yes_no_only_values)

  nil
end

- (Object) SambaLDAPSettingsMiscWidgetStore(key, event_descr)



737
738
739
740
741
742
743
744
# File '../../src/include/samba-server/ldap-widget.rb', line 737

def SambaLDAPSettingsMiscWidgetStore(key, event_descr)
  event_descr = deep_copy(event_descr)
  # store_ldap_str("ldap filter");
  store_ldap_str("ldap delete dn")
  store_ldap_str("ldap passwd sync")

  nil
end

- (Object) SambaLDAPSettingsSecurityWidgetInit(key)



679
680
681
682
683
# File '../../src/include/samba-server/ldap-widget.rb', line 679

def SambaLDAPSettingsSecurityWidgetInit(key)
  init_ldap_combo("ldap ssl", @ldap_ssl_values)

  nil
end

- (Object) SambaLDAPSettingsSecurityWidgetStore(key, event_descr)



685
686
687
688
689
690
# File '../../src/include/samba-server/ldap-widget.rb', line 685

def SambaLDAPSettingsSecurityWidgetStore(key, event_descr)
  event_descr = deep_copy(event_descr)
  store_ldap_str("ldap ssl")

  nil
end

- (Object) SambaLDAPSettingsSuffixesWidgetInit(key)

Sambs LDAP Settings Suffixes Widget ////////////////////////////////////////////////////////////////////



567
568
569
570
571
572
573
574
# File '../../src/include/samba-server/ldap-widget.rb', line 567

def SambaLDAPSettingsSuffixesWidgetInit(key)
  init_ldap_str("ldap user suffix")
  init_ldap_str("ldap group suffix")
  init_ldap_str("ldap machine suffix")
  init_ldap_str("ldap idmap suffix")

  nil
end

- (Object) SambaLDAPSettingsSuffixesWidgetStore(key, event_descr)



576
577
578
579
580
581
582
583
584
# File '../../src/include/samba-server/ldap-widget.rb', line 576

def SambaLDAPSettingsSuffixesWidgetStore(key, event_descr)
  event_descr = deep_copy(event_descr)
  store_ldap_str("ldap user suffix")
  store_ldap_str("ldap group suffix")
  store_ldap_str("ldap machine suffix")
  store_ldap_str("ldap idmap suffix")

  nil
end

- (Object) SambaLDAPSettingsTimeoutsWidgetInit(key)

Samba LDAP Settings Timeouts Widget /////////////////////////////////////////////////////////////////////////



625
626
627
628
629
630
# File '../../src/include/samba-server/ldap-widget.rb', line 625

def SambaLDAPSettingsTimeoutsWidgetInit(key)
  init_ldap_int("ldap timeout")
  init_ldap_int("ldap replication sleep")

  nil
end

- (Object) SambaLDAPSettingsTimeoutsWidgetStore(key, event_descr)



632
633
634
635
636
637
638
# File '../../src/include/samba-server/ldap-widget.rb', line 632

def SambaLDAPSettingsTimeoutsWidgetStore(key, event_descr)
  event_descr = deep_copy(event_descr)
  store_ldap_int("ldap timeout")
  store_ldap_int("ldap replication sleep")

  nil
end

- (Object) SambaLDAPTryConnect



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File '../../src/include/samba-server/ldap-widget.rb', line 177

def SambaLDAPTryConnect
  passwd1 = Convert.to_string(UI.QueryWidget(Id(:passwd1), :Value))
  passwd2 = Convert.to_string(UI.QueryWidget(Id(:passwd2), :Value))
  if passwd1 != passwd2
    Popup.Warning(_("Passwords do not match."))
    UI.SetFocus(Id(:passwd1))
    return false
  end

  admin_dn = Convert.to_string(UI.QueryWidget(Id("ldap admin dn"), :Value))

  url = nil
  if Convert.to_boolean(
      UI.QueryWidget(Id(:ldap_passdb_backend_enable), :Value)
    )
    url = Convert.to_string(
      UI.QueryWidget(Id(:ldap_passdb_backend_url), :Value)
    )
    return false if !_try_connect(url, admin_dn, passwd1)
  end

  if Convert.to_boolean(
      UI.QueryWidget(Id(:ldap_idmap_backend_enable), :Value)
    )
    idmap_url = Convert.to_string(
      UI.QueryWidget(Id(:ldap_idmap_backend_url), :Value)
    )
    if url != idmap_url
      return false if !_try_connect(idmap_url, admin_dn, passwd1)
    end
  end

  true
end

- (Object) store_ldap_int(id)



145
146
147
148
149
150
151
152
153
154
155
156
157
# File '../../src/include/samba-server/ldap-widget.rb', line 145

def store_ldap_int(id)
  val = Builtins.tostring(
    Convert.to_integer(UI.QueryWidget(Id(id), :Value))
  )
  # do not store default values
  if val == SambaBackendLDAP.GetSuseDefaultValue(id) &&
      val == SambaBackendLDAP.GetSambaDefaultValue(id)
    val = nil
  end
  SambaConfig.GlobalSetStr(id, val)

  nil
end

- (Object) store_ldap_str(id)



133
134
135
136
137
138
139
140
141
142
143
# File '../../src/include/samba-server/ldap-widget.rb', line 133

def store_ldap_str(id)
  val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
  # do not store default values
  if val == SambaBackendLDAP.GetSuseDefaultValue(id) &&
      val == SambaBackendLDAP.GetSambaDefaultValue(id)
    val = nil
  end
  SambaConfig.GlobalSetStr(id, val)

  nil
end