• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-samba-server / 10830818621

12 Sep 2024 12:29PM UTC coverage: 0.989%. First build
10830818621

push

github

lslezak
Import the changes from the OBS SLE15-SP6 project

44 of 4449 relevant lines covered (0.99%)

0.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/include/samba-server/ldap-widget.rb
1
# encoding: utf-8
2

3
# ------------------------------------------------------------------------------
4
# Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
5
#
6
#
7
# This program is free software; you can redistribute it and/or modify it under
8
# the terms of version 2 of the GNU General Public License as published by the
9
# Free Software Foundation.
10
#
11
# This program is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along with
16
# this program; if not, contact Novell, Inc.
17
#
18
# To contact Novell about this file by physical or electronic mail, you may find
19
# current contact information at www.novell.com.
20
# ------------------------------------------------------------------------------
21

22
# File:        include/samba-server/ldap-widget.ycp
23
# Package:        Configuration of samba-server
24
# Summary:        Dialogs definitions
25
# Authors:        Martin Lazar <mlazar@suse.cz>
26
#                Lukas Ocilka <locilka@suse.cz>
27
#
28
# $Id$
29
#
30
# This file contains CWM widgets related to Samba LDAP Settings:
31
#  - Samba LDAP Settings Essential Widget
32
#  - Samba LDAP Settings Suffixes Widget
33
#  - Samba LDAP Settings Timeouts Widget
34
#  - Samba LDAP Settings Misc Widget
35
module Yast
×
36
  module SambaServerLdapWidgetInclude
×
37
    def initialize_samba_server_ldap_widget(include_target)
×
38
      Yast.import "UI"
×
39

40
      textdomain "samba-server"
×
41

42
      Yast.import "URL"
×
43
      Yast.import "Popup"
×
44

45
      Yast.import "CWM"
×
46
      Yast.import "Ldap"
×
47
      Yast.import "Label"
×
48
      Yast.import "Wizard"
×
49

50
      Yast.import "SambaConfig"
×
51
      Yast.import "SambaBackend"
×
52
      Yast.import "SambaBackendLDAP"
×
53

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

56

57
      @widget_names = nil
×
58
      @widget_descr = nil
×
59

60
      # Samba LDAP Settings Security Widget
61
      #/////////////////////////////////////////////////////////////////////////
62

63
      # translators: combo box value
64
      @ldap_ssl_values = [
×
65
        ["Off", _("No")],
×
66
        # translators: combo box value
67
        ["Start_tls", _("TLS")]
×
68
      ]
×
69

70

71
      # Samba LDAP Settings Misc Widget
72
      #/////////////////////////////////////////////////////////////////////////
73

74
      # translators: combo box value
75
      @ldap_yes_no_values = [
×
76
        ["Yes", _("Yes")],
×
77
        # translators: combo box value
78
        ["No", _("No")]
×
79
      ]
×
80
      # translators: combo box value (updata password? Yes/No/Only = Only update the LDAP password and let the LDAP server do the rest)
81
      @ldap_yes_no_only_values = Convert.convert(
×
82
        Builtins.merge(@ldap_yes_no_values, [["Only", _("Only")]]),
×
83
        :from => "list",
×
84
        :to   => "list <list>"
×
85
      )
×
86
    end
×
87

88
    # helper functions
89

90
    def init_ldap_str(id)
×
91
      UI.ChangeWidget(
×
92
        Id(id),
×
93
        :Value,
×
94
        SambaConfig.GlobalGetStr(id, SambaBackendLDAP.GetSambaDefaultValue(id))
×
95
      )
×
96

97
      nil
×
98
    end
×
99

100
    def init_ldap_int(id)
×
101
      UI.ChangeWidget(
×
102
        Id(id),
×
103
        :Value,
×
104
        SambaConfig.GlobalGetInteger(
×
105
          id,
×
106
          Builtins.tointeger(SambaBackendLDAP.GetSambaDefaultValue(id))
×
107
        )
×
108
      )
×
109

110
      nil
×
111
    end
×
112

113
    def init_ldap_combo(id, m)
×
114
      m = deep_copy(m)
×
115
      val = Builtins.tolower(
×
116
        SambaConfig.GlobalGetStr(id, SambaBackendLDAP.GetSambaDefaultValue(id))
×
117
      )
×
118
      subid = nil
×
119
      Builtins.foreach(
×
120
        Convert.convert(m, :from => "list", :to => "list <list>")
×
121
      ) do |l|
×
122
        if subid == nil
×
123
          if Builtins.tolower(Ops.get_string(l, 0, "")) == val
×
124
            subid = Ops.get_string(l, 0, "")
×
125
          end
×
126
        end
×
127
      end
×
128
      UI.ChangeWidget(Id(id), :Value, subid)
×
129

130
      nil
×
131
    end
×
132

133
    def store_ldap_str(id)
×
134
      val = Convert.to_string(UI.QueryWidget(Id(id), :Value))
×
135
      # do not store default values
136
      if val == SambaBackendLDAP.GetSuseDefaultValue(id) &&
×
137
          val == SambaBackendLDAP.GetSambaDefaultValue(id)
×
138
        val = nil
×
139
      end
×
140
      SambaConfig.GlobalSetStr(id, val)
×
141

142
      nil
×
143
    end
×
144

145
    def store_ldap_int(id)
×
146
      val = Builtins.tostring(
×
147
        Convert.to_integer(UI.QueryWidget(Id(id), :Value))
×
148
      )
×
149
      # do not store default values
150
      if val == SambaBackendLDAP.GetSuseDefaultValue(id) &&
×
151
          val == SambaBackendLDAP.GetSambaDefaultValue(id)
×
152
        val = nil
×
153
      end
×
154
      SambaConfig.GlobalSetStr(id, val)
×
155

156
      nil
×
157
    end
×
158

159

160
    # Samba LDAP Settings Essential Widget
161
    #////////////////////////////////////////////////////////////////////
162

163
    def _try_connect(url, admin_dn, passwd)
×
164
      if url == ""
×
165
        # translators: popup warning message about empty text entry
166
        Popup.Warning(_("Enter the server URL."))
×
167
        return false
×
168
      end
×
169
      err = SambaBackendLDAP.TryBind(url, admin_dn, passwd)
×
170
      if err != nil
×
171
        Ldap.LDAPErrorMessage("bind", err)
×
172
        return false
×
173
      end
×
174
      true
×
175
    end
×
176

177
    def SambaLDAPTryConnect
×
178
      passwd1 = Convert.to_string(UI.QueryWidget(Id(:passwd1), :Value))
×
179
      passwd2 = Convert.to_string(UI.QueryWidget(Id(:passwd2), :Value))
×
180
      if passwd1 != passwd2
×
181
        Popup.Warning(_("Passwords do not match."))
×
182
        UI.SetFocus(Id(:passwd1))
×
183
        return false
×
184
      end
×
185

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

188
      url = nil
×
189
      if Convert.to_boolean(
×
190
          UI.QueryWidget(Id(:ldap_passdb_backend_enable), :Value)
×
191
        )
×
192
        url = Convert.to_string(
×
193
          UI.QueryWidget(Id(:ldap_passdb_backend_url), :Value)
×
194
        )
×
195
        return false if !_try_connect(url, admin_dn, passwd1)
×
196
      end
×
197

198
      if Convert.to_boolean(
×
199
          UI.QueryWidget(Id(:ldap_idmap_backend_enable), :Value)
×
200
        )
×
201
        idmap_url = Convert.to_string(
×
202
          UI.QueryWidget(Id(:ldap_idmap_backend_url), :Value)
×
203
        )
×
204
        if url != idmap_url
×
205
          return false if !_try_connect(idmap_url, admin_dn, passwd1)
×
206
        end
×
207
      end
×
208

209
      true
×
210
    end
×
211

212

213
    def SambaLDAPSettingsEssentialWidgetInit(key)
×
214
      init_ldap_str("ldap suffix")
×
215

216
      init_ldap_str("ldap admin dn")
×
217
      UI.ChangeWidget(Id(:passwd1), :Value, SambaBackendLDAP.GetAdminPassword)
×
218
      UI.ChangeWidget(Id(:passwd2), :Value, SambaBackendLDAP.GetAdminPassword)
×
219

220
      passdb_url = SambaBackendLDAP.GetPassdbServerUrl
×
221
      UI.ChangeWidget(
×
222
        Id(:ldap_passdb_backend_url),
×
223
        :Value,
×
224
        passdb_url == nil ? "" : URL.Build(passdb_url)
×
225
      )
×
226
      UI.ChangeWidget(Id(:ldap_passdb_backend_url), :Enabled, passdb_url != nil)
×
227
      UI.ChangeWidget(
×
228
        Id(:ldap_passdb_backend_enable),
×
229
        :Value,
×
230
        passdb_url != nil
×
231
      )
×
232

233
      idmap_url = SambaBackendLDAP.GetIdmapServerUrl
×
234
      UI.ChangeWidget(
×
235
        Id(:ldap_idmap_backend_url),
×
236
        :Value,
×
237
        idmap_url == nil ? "" : URL.Build(idmap_url)
×
238
      )
×
239
      UI.ChangeWidget(Id(:ldap_idmap_backend_url), :Enabled, idmap_url != nil)
×
240
      UI.ChangeWidget(Id(:ldap_idmap_backend_enable), :Value, idmap_url != nil)
×
241

242
      Builtins.foreach(
×
243
        [
×
244
          "ldap suffix",
×
245
          "ldap admin dn",
×
246
          :passwd1,
×
247
          :passwd2,
×
248
          :ldap_try_connect,
×
249
          :ldap_advanced_settings
×
250
        ]
×
251
      ) do |id|
×
252
        UI.ChangeWidget(Id(id), :Enabled, idmap_url != nil || passdb_url != nil)
×
253
      end
×
254

255
      UI.SetFocus(Id(:passwd1))
×
256

257
      nil
×
258
    end
×
259

260
    def ProposeDefaultValues
×
261
      SambaConfig.GlobalSetMap(SambaBackendLDAP.GetSuseDefaultValues)
×
262
      if Ldap.server != nil && Ldap.server != ""
×
263
        SambaConfig.GlobalSetStr(
×
264
          "idmap backend",
×
265
          Ops.add("ldap:ldap://", Ldap.GetFirstServer(Ldap.server))
×
266
        )
×
267
        SambaBackend.AddPassdbBackend(
×
268
          "ldapsam",
×
269
          Ops.add("ldap://", Ldap.GetFirstServer(Ldap.server))
×
270
        )
×
271
      else
×
272
        SambaConfig.GlobalSetStr("idmap backend", nil)
×
273
        SambaBackend.RemovePassdbBackend("ldapsam")
×
274
      end
×
275
      nil
×
276
    end
×
277

278
    def SambaLDAPSettingsEssentialWidgetHandle(key, event_descr)
×
279
      event_descr = deep_copy(event_descr)
×
280
      id = Ops.get(event_descr, "ID")
×
281

282
      if id == :passwd1 || id == :passwd2
×
283
        passwd1 = Convert.to_string(UI.QueryWidget(Id(:passwd1), :Value))
×
284
        passwd2 = Convert.to_string(UI.QueryWidget(Id(:passwd2), :Value))
×
285
        if passwd1 != passwd2
×
286
          # translators: inform text
287
          UI.ReplaceWidget(
×
288
            Id("passwd_label"),
×
289
            Left(Label(_("Passwords do not match.")))
×
290
          )
×
291
          UI.ChangeWidget(Id(:ldap_try_connect), :Enabled, false)
×
292
          UI.SetFocus(Id(:passwd2))
×
293
        elsif passwd1 == SambaBackendLDAP.GetAdminPassword
×
294
          UI.ReplaceWidget(Id("passwd_label"), Left(Label("")))
×
295
          UI.ChangeWidget(Id(:ldap_try_connect), :Enabled, true)
×
296
        else
×
297
          # translators: inform text
298
          UI.ReplaceWidget(
×
299
            Id("passwd_label"),
×
300
            Left(Label(_("Passwords match.")))
×
301
          )
×
302
          UI.ChangeWidget(Id(:ldap_try_connect), :Enabled, true)
×
303
        end
×
304
      elsif id == :ldap_passdb_backend_enable ||
×
305
          id == :ldap_idmap_backend_enable
×
306
        passdb = Convert.to_boolean(
×
307
          UI.QueryWidget(Id(:ldap_passdb_backend_enable), :Value)
×
308
        )
×
309
        UI.ChangeWidget(Id(:ldap_passdb_backend_url), :Enabled, passdb)
×
310

311
        idmap = Convert.to_boolean(
×
312
          UI.QueryWidget(Id(:ldap_idmap_backend_enable), :Value)
×
313
        )
×
314
        UI.ChangeWidget(Id(:ldap_idmap_backend_url), :Enabled, idmap)
×
315

316
        Builtins.foreach(
×
317
          [
×
318
            "ldap suffix",
×
319
            "ldap admin dn",
×
320
            :passwd1,
×
321
            :passwd2,
×
322
            :ldap_try_connect,
×
323
            :ldap_advanced_settings
×
324
          ]
×
325
        ) { |id2| UI.ChangeWidget(Id(id2), :Enabled, idmap || passdb) }
×
326

327
        # Propose default values
328
        if passdb || idmap
×
329
          some_values_filled = false
×
330
          Builtins.foreach(
×
331
            [
×
332
              :passwd1,
×
333
              :passwd2,
×
334
              :ldap_passdb_backend_url,
×
335
              :ldap_passdb_backend_url,
×
336
              :ldap_idmap_backend_url,
×
337
              :ldap_idmap_backend_url
×
338
            ]
×
339
          ) do |ui_widget_setting|
×
340
            read_value = Convert.to_string(
×
341
              UI.QueryWidget(Id(ui_widget_setting), :Value)
×
342
            )
×
343
            if read_value != "" && read_value != nil
×
344
              some_values_filled = true
×
345
              raise Break
×
346
            end
×
347
          end
×
348

349
          if some_values_filled == false &&
×
350
              Popup.YesNo(
×
351
                _(
×
352
                  "All current LDAP-related values will be rewritten.\nContinue?\n"
×
353
                )
×
354
              )
×
355
            Builtins.y2milestone("Proposing default values...")
×
356
            ProposeDefaultValues()
×
357
          end
×
358
        end
×
359
      elsif id == :ldap_expert_settings
×
360
        SambaLDAPExpertSettingsDialog()
×
361
      elsif id == :ldap_try_connect
×
362
        if SambaLDAPTryConnect()
×
363
          # translators: popup message
364
          Popup.Message(_("Connection successful."))
×
365
        end
×
366
      elsif id == :ldap_suse_defaults
×
367
        # translators: popup message
368
        if Popup.YesNo(
×
369
            _("All current LDAP-related values will be rewritten.\nContinue?\n")
×
370
          )
×
371
          ProposeDefaultValues()
×
372
        end
×
373
      end
×
374

375
      nil
×
376
    end
×
377

378
    def SambaLDAPSettingsEssentialWidgetValidate(key, event)
×
379
      event = deep_copy(event)
×
380
      passdb = Convert.to_boolean(
×
381
        UI.QueryWidget(Id(:ldap_passdb_backend_enable), :Value)
×
382
      )
×
383
      idmap = Convert.to_boolean(
×
384
        UI.QueryWidget(Id(:ldap_idmap_backend_enable), :Value)
×
385
      )
×
386
      return true if !passdb && !idmap
×
387

388
      return false if !SambaLDAPTryConnect()
×
389

390
      true
×
391
    end
×
392

393
    def SambaLDAPSettingsEssentialWidgetStore(key, event_descr)
×
394
      event_descr = deep_copy(event_descr)
×
395
      store_ldap_str("ldap admin dn")
×
396
      store_ldap_str("ldap suffix")
×
397

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

401
      passdb = Convert.to_boolean(
×
402
        UI.QueryWidget(Id(:ldap_passdb_backend_enable), :Value)
×
403
      )
×
404
      idmap = Convert.to_boolean(
×
405
        UI.QueryWidget(Id(:ldap_idmap_backend_enable), :Value)
×
406
      )
×
407

408
      if passdb
×
409
        passdb_url = Convert.to_string(
×
410
          UI.QueryWidget(Id(:ldap_passdb_backend_url), :Value)
×
411
        )
×
412
        SambaBackend.AddPassdbBackend("ldapsam", passdb_url)
×
413
      else
×
414
        SambaBackend.RemovePassdbBackend("ldapsam")
×
415
      end
×
416

417
      if idmap
×
418
        idmap_url = Convert.to_string(
×
419
          UI.QueryWidget(Id(:ldap_idmap_backend_url), :Value)
×
420
        )
×
421
        SambaConfig.GlobalSetStr("idmap backend", Ops.add("ldap:", idmap_url))
×
422
      else
×
423
        SambaConfig.GlobalSetStr("idmap backend", nil)
×
424
      end
×
425

426
      nil
×
427
    end
×
428

429
    def CreateSambaLDAPSettingsEssentialWidget
×
430
      basedn = VBox(
×
431
        # translators: text entry label
432
        TextEntry(Id("ldap suffix"), _("&Search Base DN"))
×
433
      )
×
434
      auth = Frame(
×
435
        _("Authentication"),
×
436
        VBox(
×
437
          # translators: text entry label
438
          TextEntry(Id("ldap admin dn"), _("&Administration DN")),
×
439
          # BNC #446794
440
          HSquash(
×
441
            VBox(
×
442
              # TODO: if Mode::config() => no ask for pssword
443
              # translators: password enrty label
444
              Password(
×
445
                Id(:passwd1),
×
446
                Opt(:hstretch),
×
447
                _("Administration &Password")
×
448
              ),
×
449
              # translators: reenter password entry label
450
              Password(
×
451
                Id(:passwd2),
×
452
                Opt(:hstretch),
×
453
                _("Administration Password (A&gain)")
×
454
              )
×
455
            )
×
456
          ),
×
457
          ReplacePoint(Id("passwd_label"), Label("")),
×
458
          Empty(Opt(:vstretch))
×
459
        )
×
460
      )
×
461
      passdb =
×
462
        # translators: frame title (passdb == password database)
463
        Frame(
×
464
          _("Passdb Back-End"),
×
465
          VBox(
×
466
            # translators: check box label
467
            Left(
×
468
              CheckBox(
×
469
                Id(:ldap_passdb_backend_enable),
×
470
                Opt(:notify),
×
471
                _("Use LDAP Password &Back-End")
×
472
              )
×
473
            ),
×
474
            # translators: text entry label
475
            TextEntry(Id(:ldap_passdb_backend_url), _("LDAP Server &URL")),
×
476
            Empty(Opt(:vstretch))
×
477
          )
×
478
        )
×
479

480
      idmap =
×
481
        # translators: frame title (idmap = user id mapping)
482
        Frame(
×
483
          _("Idmap Back-End"),
×
484
          VBox(
×
485
            # translators: check box label
486
            Left(
×
487
              CheckBox(
×
488
                Id(:ldap_idmap_backend_enable),
×
489
                Opt(:notify),
×
490
                _("Use LDAP &Idmap Back-End")
×
491
              )
×
492
            ),
×
493
            # translators: text entry label
494
            TextEntry(Id(:ldap_idmap_backend_url), _("LDAP Server U&RL")),
×
495
            Empty(Opt(:vstretch))
×
496
          )
×
497
        )
×
498

499

500
      essential_widget = Top(
×
501
        HBox(
×
502
          HSpacing(1),
×
503
          VBox(
×
504
            VWeight(1, Empty()),
×
505
            VSquash(
×
506
              HBox(
×
507
                HWeight(1, VBox(passdb, idmap)),
×
508
                HSpacing(1),
×
509
                HWeight(1, auth)
×
510
              )
×
511
            ),
×
512
            VWeight(1, Empty()),
×
513
            basedn,
×
514
            VWeight(8, Empty()),
×
515
            Right(
×
516
              HBox(
×
517
                PushButton(Id(:ldap_try_connect), _("&Test Connection")),
×
518
                MenuButton(
×
519
                  Id(:ldap_advanced_settings),
×
520
                  _("Advanced &Settings..."),
×
521
                  [
×
522
                    Item(Id(:ldap_expert_settings), _("Expert LDAP Settings")),
×
523
                    Item(Id(:ldap_suse_defaults), _("Default Values"))
×
524
                  ]
×
525
                )
×
526
              )
×
527
            )
×
528
          ),
×
529
          HSpacing(1)
×
530
        )
×
531
      )
×
532

533
      {
×
534
        "widget"            => :custom,
×
535
        "custom_widget"     => essential_widget,
×
536
        "init"              => fun_ref(
×
537
          method(:SambaLDAPSettingsEssentialWidgetInit),
×
538
          "void (string)"
×
539
        ),
×
540
        "handle"            => fun_ref(
×
541
          method(:SambaLDAPSettingsEssentialWidgetHandle),
×
542
          "symbol (string, map)"
×
543
        ),
×
544
        "store"             => fun_ref(
×
545
          method(:SambaLDAPSettingsEssentialWidgetStore),
×
546
          "void (string, map)"
×
547
        ),
×
548
        "validate_type"     => :function,
×
549
        "validate_function" => fun_ref(
×
550
          method(:SambaLDAPSettingsEssentialWidgetValidate),
×
551
          "boolean (string, map)"
×
552
        ),
×
553
        "help"              => Ops.get_string(
×
554
          @HELPS,
×
555
          "samba_ldap_setting_auth_widget",
×
556
          ""
×
557
        )
×
558
      }
×
559
    end
×
560

561

562
    # Sambs LDAP Settings Suffixes Widget
563
    #////////////////////////////////////////////////////////////////////
564

565
    def SambaLDAPSettingsSuffixesWidgetInit(key)
×
566
      init_ldap_str("ldap user suffix")
×
567
      init_ldap_str("ldap group suffix")
×
568
      init_ldap_str("ldap machine suffix")
×
569
      init_ldap_str("ldap idmap suffix")
×
570

571
      nil
×
572
    end
×
573

574
    def SambaLDAPSettingsSuffixesWidgetStore(key, event_descr)
×
575
      event_descr = deep_copy(event_descr)
×
576
      store_ldap_str("ldap user suffix")
×
577
      store_ldap_str("ldap group suffix")
×
578
      store_ldap_str("ldap machine suffix")
×
579
      store_ldap_str("ldap idmap suffix")
×
580

581
      nil
×
582
    end
×
583

584
    def CreateSambaLDAPSettingsSuffixesWidget
×
585
      # translators: frame label
586
      suffixes_widget = Frame(
×
587
        _("Suffixes"),
×
588
        VBox(
×
589
          # translators: text entry label
590
          Left(TextEntry(Id("ldap user suffix"), _("&User Suffix"))),
×
591
          # translators: text entry label
592
          Left(TextEntry(Id("ldap group suffix"), _("&Group Suffix"))),
×
593
          # translators: text entry label
594
          Left(TextEntry(Id("ldap machine suffix"), _("&Machine Suffix"))),
×
595
          # translators: text entry label
596
          Left(TextEntry(Id("ldap idmap suffix"), _("&Idmap Suffix")))
×
597
        )
×
598
      )
×
599

600
      {
×
601
        "widget"        => :custom,
×
602
        "custom_widget" => suffixes_widget,
×
603
        "init"          => fun_ref(
×
604
          method(:SambaLDAPSettingsSuffixesWidgetInit),
×
605
          "void (string)"
×
606
        ),
×
607
        "store"         => fun_ref(
×
608
          method(:SambaLDAPSettingsSuffixesWidgetStore),
×
609
          "void (string, map)"
×
610
        ),
×
611
        "help"          => Ops.get_string(
×
612
          @HELPS,
×
613
          "samba_ldap_setting_suffixes_widget",
×
614
          ""
×
615
        )
×
616
      }
×
617
    end
×
618

619

620
    # Samba LDAP Settings Timeouts Widget
621
    #/////////////////////////////////////////////////////////////////////////
622

623
    def SambaLDAPSettingsTimeoutsWidgetInit(key)
×
624
      init_ldap_int("ldap timeout")
×
625
      init_ldap_int("ldap replication sleep")
×
626

627
      nil
×
628
    end
×
629

630
    def SambaLDAPSettingsTimeoutsWidgetStore(key, event_descr)
×
631
      event_descr = deep_copy(event_descr)
×
632
      store_ldap_int("ldap timeout")
×
633
      store_ldap_int("ldap replication sleep")
×
634

635
      nil
×
636
    end
×
637

638
    def CreateSambaLDAPSettingsTimeoutsWidget
×
639
      # translators: frame label
640
      timeouts_widget = Frame(
×
641
        _("Time-Outs"),
×
642
        VBox(
×
643
          # translators: integer field label
644
          Left(
×
645
            IntField(
×
646
              Id("ldap replication sleep"),
×
647
              _("&Replication Sleep"),
×
648
              0,
×
649
              999999,
×
650
              3
×
651
            )
×
652
          ),
×
653
          # translators: integer field label
654
          Left(IntField(Id("ldap timeout"), _("&Time-Out"), 0, 999999, 3))
×
655
        )
×
656
      )
×
657

658
      {
×
659
        "widget"        => :custom,
×
660
        "custom_widget" => timeouts_widget,
×
661
        "init"          => fun_ref(
×
662
          method(:SambaLDAPSettingsTimeoutsWidgetInit),
×
663
          "void (string)"
×
664
        ),
×
665
        "store"         => fun_ref(
×
666
          method(:SambaLDAPSettingsTimeoutsWidgetStore),
×
667
          "void (string, map)"
×
668
        ),
×
669
        "help"          => Ops.get_string(
×
670
          @HELPS,
×
671
          "samba_ldap_settings_timeouts_widget",
×
672
          ""
×
673
        )
×
674
      }
×
675
    end
×
676

677
    def SambaLDAPSettingsSecurityWidgetInit(key)
×
678
      init_ldap_combo("ldap ssl", @ldap_ssl_values)
×
679

680
      nil
×
681
    end
×
682

683
    def SambaLDAPSettingsSecurityWidgetStore(key, event_descr)
×
684
      event_descr = deep_copy(event_descr)
×
685
      store_ldap_str("ldap ssl")
×
686

687
      nil
×
688
    end
×
689

690
    def CreateSambaLDAPSettingsSecurityWidget
×
691
      # translators: frame label
692
      widget = Frame(
×
693
        _("Security"),
×
694
        VBox(
×
695
          # translators: combo box label
696
          Left(
×
697
            ComboBox(
×
698
              Id("ldap ssl"),
×
699
              _("&Use SSL or TLS"),
×
700
              Builtins.maplist(@ldap_ssl_values) do |l|
×
701
                Item(Id(Ops.get_string(l, 0, "")), Ops.get_string(l, 1, ""))
×
702
              end
×
703
            )
×
704
          )
×
705
        )
×
706
      )
×
707

708
      {
×
709
        "widget"        => :custom,
×
710
        "custom_widget" => widget,
×
711
        "init"          => fun_ref(
×
712
          method(:SambaLDAPSettingsSecurityWidgetInit),
×
713
          "void (string)"
×
714
        ),
×
715
        "store"         => fun_ref(
×
716
          method(:SambaLDAPSettingsSecurityWidgetStore),
×
717
          "void (string, map)"
×
718
        ),
×
719
        "help"          => Ops.get_string(
×
720
          @HELPS,
×
721
          "samba_ldap_settings_security_widget",
×
722
          ""
×
723
        )
×
724
      }
×
725
    end
×
726

727
    def SambaLDAPSettingsMiscWidgetInit(key)
×
728
      # init_ldap_str("ldap filter");
729
      init_ldap_combo("ldap delete dn", @ldap_yes_no_values)
×
730
      init_ldap_combo("ldap passwd sync", @ldap_yes_no_only_values)
×
731

732
      nil
×
733
    end
×
734

735
    def SambaLDAPSettingsMiscWidgetStore(key, event_descr)
×
736
      event_descr = deep_copy(event_descr)
×
737
      # store_ldap_str("ldap filter");
738
      store_ldap_str("ldap delete dn")
×
739
      store_ldap_str("ldap passwd sync")
×
740

741
      nil
×
742
    end
×
743

744
    def CreateSambaLDAPSettingsMiscWidget
×
745
      # translators: frame label
746
      misc_widget = Frame(
×
747
        _("Other Settings"),
×
748
        VBox(
×
749
          # No such option, bug 169194
750
          # translators: text entry label
751
          # `Left(`TextEntry(`id("ldap filter"), _("Search &Filter"))),
752

753
          # translators: combo box label
754
          Left(
×
755
            ComboBox(
×
756
              Id("ldap delete dn"),
×
757
              _("&Delete DN"),
×
758
              Builtins.maplist(@ldap_yes_no_values) do |l|
×
759
                Item(Id(Ops.get_string(l, 0, "")), Ops.get_string(l, 1, ""))
×
760
              end
×
761
            )
×
762
          ),
×
763
          # translators: combo box label
764
          Left(
×
765
            ComboBox(
×
766
              Id("ldap passwd sync"),
×
767
              _("&Synchronize Passwords"),
×
768
              Builtins.maplist(@ldap_yes_no_only_values) do |l|
×
769
                Item(Id(Ops.get_string(l, 0, "")), Ops.get_string(l, 1, ""))
×
770
              end
×
771
            )
×
772
          )
×
773
        )
×
774
      )
×
775

776
      {
×
777
        "widget"        => :custom,
×
778
        "custom_widget" => misc_widget,
×
779
        "init"          => fun_ref(
×
780
          method(:SambaLDAPSettingsMiscWidgetInit),
×
781
          "void (string)"
×
782
        ),
×
783
        "store"         => fun_ref(
×
784
          method(:SambaLDAPSettingsMiscWidgetStore),
×
785
          "void (string, map)"
×
786
        ),
×
787
        "help"          => Ops.get_string(
×
788
          @HELPS,
×
789
          "samba_ldap_settings_misc_widget",
×
790
          ""
×
791
        )
×
792
      }
×
793
    end
×
794
    def SambaLDAPExpertSettingsDialog
×
795
      widget_descr = {
×
796
        "SUFFIXES" => CreateSambaLDAPSettingsSuffixesWidget(),
×
797
        "TIMEOUTS" => CreateSambaLDAPSettingsTimeoutsWidget(),
×
798
        "SECURITY" => CreateSambaLDAPSettingsSecurityWidget(),
×
799
        "MISC"     => CreateSambaLDAPSettingsMiscWidget()
×
800
      }
×
801

802
      contents = VBox(
×
803
        HBox(
×
804
          HSpacing(1),
×
805
          HWeight(1, VBox("SECURITY", "SUFFIXES", Empty(Opt(:vstretch)))),
×
806
          HSpacing(1),
×
807
          HWeight(1, VBox("TIMEOUTS", "MISC", Empty(Opt(:vstretch)))),
×
808
          HSpacing(1)
×
809
        ),
×
810
        VStretch()
×
811
      )
×
812

813
      Wizard.CreateDialog
×
814
      ret = CWM.ShowAndRun(
×
815
        {
×
816
          "widget_names" => ["SUFFIXES", "TIMEOUTS", "SECURITY", "MISC"],
×
817
          "widget_descr" => widget_descr,
×
818
          "contents"     => contents,
×
819
          # translators: dialog caption
820
          "caption"      => _(
×
821
            "Expert LDAP Settings"
×
822
          ),
×
823
          "back_button"  => Label.CancelButton,
×
824
          "next_button"  => Label.OKButton,
×
825
          "abort_button" => nil
×
826
        }
×
827
      )
×
828
      UI.CloseDialog
×
829

830
      ret
×
831
    end
×
832
  end
×
833
end
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc