Class: Jamf::DirectoryBindingType::ActiveDirectory

Inherits:
Jamf::DirectoryBindingType show all
Defined in:
lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb

Overview

Class for the specific Active Directory DirectoryBinding type stored within the JSS

Attributes TODO: Include default values upon creation

Author:

  • Tyler Morgan

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(init_data) ⇒ ActiveDirectory

An initializer for the Active Directory object.

Parameters:

  • initialize (Hash)

    data

See Also:

Author:

  • Tyler Morgan



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 96

def initialize(init_data)

    # Return without processing anything since there is
    # nothing to process.
    return if init_data.nil?

    # Process provided information
    @cache_last_user = init_data[:cache_last_user]
    @require_confirmation = init_data[:require_confirmation]
    @local_home = init_data[:local_home]
    @use_unc_path = init_data[:use_unc_path]
    @default_shell = init_data[:default_shell]
    @uid = init_data[:uid]
    @user_gid = init_data[:user_gid]
    @gid = init_data[:gid]
    @multiple_domains = init_data[:multiple_domains]
    @preferred_domain = init_data[:preferred_domain]
    @forest = init_data[:forest]

    if init_data[:mount_style].nil? || init_data[:mount_style].is_a?(String)
        raise Jamf::InvalidDataError, "Mount style must be one of #{NETWORK_PROTOCOL.values.join(', ')}." unless NETWORK_PROTOCOL.values.map { |x| x.downcase }.include?(init_data[:mount_style].downcase) || init_data[:mount_style].nil? 
        @mount_style = init_data[:mount_style]
    else
        raise Jamf::InvalidDataError, "Mount style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}," unless NETWORK_PROTOCOL.keys.include? init_data[:mount_style]

        @mount_style = NETWORK_PROTOCOL[init_data[:mount_style]]
    end

    if init_data[:admin_groups].nil?
        # This is needed since we have the ability to add and
        # remove admin groups from this array.
        @admin_groups = []
    elsif init_data[:admin_groups].is_a? String
        @admin_groups = init_data[:admin_groups].split(',')
    else
        @admin_groups = init_data[:admin_groups]
    end
end

Instance Attribute Details

#admin_groupsObject

Class for the specific Active Directory DirectoryBinding type stored within the JSS

Attributes TODO: Include default values upon creation

Author:

  • Tyler Morgan



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
211
212
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
430
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
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 60

class ActiveDirectory < DirectoryBindingType
    # Mix-Ins
    #####################################

    # Class Methods
    #####################################

    # Class Constants
    #####################################

    # Attributes
    #####################################
    attr_reader :cache_last_user
    attr_reader :require_confirmation
    attr_reader :local_home
    attr_reader :use_unc_path
    attr_reader :mount_style
    attr_reader :default_shell
    attr_reader :uid
    attr_reader :user_gid
    attr_reader :gid
    attr_reader :multiple_domains
    attr_reader :preferred_domain
    attr_reader :admin_groups
    attr_reader :forest

    # Constructor
    #####################################

    # An initializer for the Active Directory object.
    # 
    # @author Tyler Morgan
    # @see Jamf::DirectoryBinding
    # @see Jamf::DirectoryBindingType
    #
    # @param [Hash] initialize data
    def initialize(init_data)

        # Return without processing anything since there is
        # nothing to process.
        return if init_data.nil?

        # Process provided information
        @cache_last_user = init_data[:cache_last_user]
        @require_confirmation = init_data[:require_confirmation]
        @local_home = init_data[:local_home]
        @use_unc_path = init_data[:use_unc_path]
        @default_shell = init_data[:default_shell]
        @uid = init_data[:uid]
        @user_gid = init_data[:user_gid]
        @gid = init_data[:gid]
        @multiple_domains = init_data[:multiple_domains]
        @preferred_domain = init_data[:preferred_domain]
        @forest = init_data[:forest]

        if init_data[:mount_style].nil? || init_data[:mount_style].is_a?(String)
            raise Jamf::InvalidDataError, "Mount style must be one of #{NETWORK_PROTOCOL.values.join(', ')}." unless NETWORK_PROTOCOL.values.map { |x| x.downcase }.include?(init_data[:mount_style].downcase) || init_data[:mount_style].nil? 
            @mount_style = init_data[:mount_style]
        else
            raise Jamf::InvalidDataError, "Mount style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}," unless NETWORK_PROTOCOL.keys.include? init_data[:mount_style]

            @mount_style = NETWORK_PROTOCOL[init_data[:mount_style]]
        end

        if init_data[:admin_groups].nil?
            # This is needed since we have the ability to add and
            # remove admin groups from this array.
            @admin_groups = []
        elsif init_data[:admin_groups].is_a? String
            @admin_groups = init_data[:admin_groups].split(',')
        else
            @admin_groups = init_data[:admin_groups]
        end
    end

        

    # Public Instance Methods
    #####################################

    # Create mobile account upon login
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def cache_last_user=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "cache_last_user must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @cache_last_user = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Require confirmation before creating a mobile account on the system.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def require_confirmation=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @require_confirmation = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Force local home directory to be placed on the startup disk
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def local_home=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "local_home must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @local_home = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Attempt to derive the network home location using the UNC path stored inside Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def use_unc_path=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "use_unc_path must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @use_unc_path = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The protocol to be use when mounting network home location
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Symbol] One of the keys available in NETWORK_PROTOCOL
    # @see Jamf::DIRECTORYBINDINGTYPE::NETWORK_PROTOCOL
    #
    # @raise [Jamf::InvalidDataError] If the new value provided is not a key inside the NETWORK_PROTOCOL hash.
    #
    # @return [void]
    def mount_style=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "mount_style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}." unless NETWORK_PROTOCOL.keys.include? newvalue

        # Update Value
        @mount_style = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The directory path to the shell user's default shell will be set to upon login.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] Directory path for the specific shell that is wanting to be set.
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def default_shell=(newvalue)

        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @default_shell = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a UID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The UID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def uid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @uid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Specify a specific forest within Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The forest you want to specify
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def forest=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
                newvalue
            end
        
        # Update Value
        @forest = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    # Map specific a User's GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The User's GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def user_gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @user_gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end
        
        # Update Value
        @gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Will this computer be possibly connecting to multiple domains
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a Bool.
    #
    # @return [void]
    def multiple_domains=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "multiple_domains must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @multiple_domains = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # What domain server should be highest priority
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a String.
    #
    # @return [void]
    def preferred_domain=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @preferred_domain = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The AD group which can be considered administrators of a device.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Array <String>]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not an Array.
    #
    # @return [void]
    def admin_groups=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
                
                if newvalue.is_a? Array
                    newvalue.join ","
                else
                    newvalue
                end
            end
            
        # Update Value
        @admin_groups = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Add a specific admin group to the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to add to the admin group list
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def add_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Group \"#{value}\" already is in the admin groups." unless !@admin_groups.include? value

        @admin_groups << value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Remove a specific admin group from the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to remove from the admin groups.
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def remove_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group being removed must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_groups.include? value

        @admin_groups.delete value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Return a REXML Element containing the current state of the DirectoryBindingType
    # object for adding into the XML of the container.
    # 
    # @author Tyler Morgan
    #
    # @return [REXML::Element]
    def type_setting_xml
        type_setting = REXML::Element.new "active_directory"
        type_setting.add_element("cache_last_user").text = @cache_last_user
        type_setting.add_element("require_confirmation").text = @require_confirmation
        type_setting.add_element("local_home").text = @local_home
        type_setting.add_element("use_unc_path").text = @use_unc_path
        type_setting.add_element("mount_style").text = @mount_style.downcase
        type_setting.add_element("default_shell").text = @default_shell
        type_setting.add_element("uid").text = @uid
        type_setting.add_element("user_gid").text = @user_gid
        type_setting.add_element("gid").text = @gid
        type_setting.add_element("multiple_domains").text = @multiple_domains
        type_setting.add_element("preferred_domain").text = @preferred_domain
        type_setting.add_element("admin_groups").text = @admin_groups.join(',').to_s unless @admin_groups.nil?
        type_setting.add_element("forest").text = @forest.to_s

        return type_setting
    end
end

#cache_last_userObject

Attributes



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
211
212
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
430
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
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 60

class ActiveDirectory < DirectoryBindingType
    # Mix-Ins
    #####################################

    # Class Methods
    #####################################

    # Class Constants
    #####################################

    # Attributes
    #####################################
    attr_reader :cache_last_user
    attr_reader :require_confirmation
    attr_reader :local_home
    attr_reader :use_unc_path
    attr_reader :mount_style
    attr_reader :default_shell
    attr_reader :uid
    attr_reader :user_gid
    attr_reader :gid
    attr_reader :multiple_domains
    attr_reader :preferred_domain
    attr_reader :admin_groups
    attr_reader :forest

    # Constructor
    #####################################

    # An initializer for the Active Directory object.
    # 
    # @author Tyler Morgan
    # @see Jamf::DirectoryBinding
    # @see Jamf::DirectoryBindingType
    #
    # @param [Hash] initialize data
    def initialize(init_data)

        # Return without processing anything since there is
        # nothing to process.
        return if init_data.nil?

        # Process provided information
        @cache_last_user = init_data[:cache_last_user]
        @require_confirmation = init_data[:require_confirmation]
        @local_home = init_data[:local_home]
        @use_unc_path = init_data[:use_unc_path]
        @default_shell = init_data[:default_shell]
        @uid = init_data[:uid]
        @user_gid = init_data[:user_gid]
        @gid = init_data[:gid]
        @multiple_domains = init_data[:multiple_domains]
        @preferred_domain = init_data[:preferred_domain]
        @forest = init_data[:forest]

        if init_data[:mount_style].nil? || init_data[:mount_style].is_a?(String)
            raise Jamf::InvalidDataError, "Mount style must be one of #{NETWORK_PROTOCOL.values.join(', ')}." unless NETWORK_PROTOCOL.values.map { |x| x.downcase }.include?(init_data[:mount_style].downcase) || init_data[:mount_style].nil? 
            @mount_style = init_data[:mount_style]
        else
            raise Jamf::InvalidDataError, "Mount style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}," unless NETWORK_PROTOCOL.keys.include? init_data[:mount_style]

            @mount_style = NETWORK_PROTOCOL[init_data[:mount_style]]
        end

        if init_data[:admin_groups].nil?
            # This is needed since we have the ability to add and
            # remove admin groups from this array.
            @admin_groups = []
        elsif init_data[:admin_groups].is_a? String
            @admin_groups = init_data[:admin_groups].split(',')
        else
            @admin_groups = init_data[:admin_groups]
        end
    end

        

    # Public Instance Methods
    #####################################

    # Create mobile account upon login
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def cache_last_user=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "cache_last_user must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @cache_last_user = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Require confirmation before creating a mobile account on the system.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def require_confirmation=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @require_confirmation = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Force local home directory to be placed on the startup disk
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def local_home=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "local_home must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @local_home = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Attempt to derive the network home location using the UNC path stored inside Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def use_unc_path=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "use_unc_path must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @use_unc_path = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The protocol to be use when mounting network home location
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Symbol] One of the keys available in NETWORK_PROTOCOL
    # @see Jamf::DIRECTORYBINDINGTYPE::NETWORK_PROTOCOL
    #
    # @raise [Jamf::InvalidDataError] If the new value provided is not a key inside the NETWORK_PROTOCOL hash.
    #
    # @return [void]
    def mount_style=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "mount_style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}." unless NETWORK_PROTOCOL.keys.include? newvalue

        # Update Value
        @mount_style = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The directory path to the shell user's default shell will be set to upon login.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] Directory path for the specific shell that is wanting to be set.
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def default_shell=(newvalue)

        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @default_shell = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a UID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The UID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def uid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @uid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Specify a specific forest within Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The forest you want to specify
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def forest=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
                newvalue
            end
        
        # Update Value
        @forest = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    # Map specific a User's GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The User's GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def user_gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @user_gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end
        
        # Update Value
        @gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Will this computer be possibly connecting to multiple domains
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a Bool.
    #
    # @return [void]
    def multiple_domains=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "multiple_domains must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @multiple_domains = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # What domain server should be highest priority
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a String.
    #
    # @return [void]
    def preferred_domain=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @preferred_domain = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The AD group which can be considered administrators of a device.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Array <String>]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not an Array.
    #
    # @return [void]
    def admin_groups=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
                
                if newvalue.is_a? Array
                    newvalue.join ","
                else
                    newvalue
                end
            end
            
        # Update Value
        @admin_groups = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Add a specific admin group to the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to add to the admin group list
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def add_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Group \"#{value}\" already is in the admin groups." unless !@admin_groups.include? value

        @admin_groups << value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Remove a specific admin group from the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to remove from the admin groups.
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def remove_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group being removed must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_groups.include? value

        @admin_groups.delete value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Return a REXML Element containing the current state of the DirectoryBindingType
    # object for adding into the XML of the container.
    # 
    # @author Tyler Morgan
    #
    # @return [REXML::Element]
    def type_setting_xml
        type_setting = REXML::Element.new "active_directory"
        type_setting.add_element("cache_last_user").text = @cache_last_user
        type_setting.add_element("require_confirmation").text = @require_confirmation
        type_setting.add_element("local_home").text = @local_home
        type_setting.add_element("use_unc_path").text = @use_unc_path
        type_setting.add_element("mount_style").text = @mount_style.downcase
        type_setting.add_element("default_shell").text = @default_shell
        type_setting.add_element("uid").text = @uid
        type_setting.add_element("user_gid").text = @user_gid
        type_setting.add_element("gid").text = @gid
        type_setting.add_element("multiple_domains").text = @multiple_domains
        type_setting.add_element("preferred_domain").text = @preferred_domain
        type_setting.add_element("admin_groups").text = @admin_groups.join(',').to_s unless @admin_groups.nil?
        type_setting.add_element("forest").text = @forest.to_s

        return type_setting
    end
end

#default_shellObject

Class for the specific Active Directory DirectoryBinding type stored within the JSS

Attributes TODO: Include default values upon creation

Author:

  • Tyler Morgan



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
211
212
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
430
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
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 60

class ActiveDirectory < DirectoryBindingType
    # Mix-Ins
    #####################################

    # Class Methods
    #####################################

    # Class Constants
    #####################################

    # Attributes
    #####################################
    attr_reader :cache_last_user
    attr_reader :require_confirmation
    attr_reader :local_home
    attr_reader :use_unc_path
    attr_reader :mount_style
    attr_reader :default_shell
    attr_reader :uid
    attr_reader :user_gid
    attr_reader :gid
    attr_reader :multiple_domains
    attr_reader :preferred_domain
    attr_reader :admin_groups
    attr_reader :forest

    # Constructor
    #####################################

    # An initializer for the Active Directory object.
    # 
    # @author Tyler Morgan
    # @see Jamf::DirectoryBinding
    # @see Jamf::DirectoryBindingType
    #
    # @param [Hash] initialize data
    def initialize(init_data)

        # Return without processing anything since there is
        # nothing to process.
        return if init_data.nil?

        # Process provided information
        @cache_last_user = init_data[:cache_last_user]
        @require_confirmation = init_data[:require_confirmation]
        @local_home = init_data[:local_home]
        @use_unc_path = init_data[:use_unc_path]
        @default_shell = init_data[:default_shell]
        @uid = init_data[:uid]
        @user_gid = init_data[:user_gid]
        @gid = init_data[:gid]
        @multiple_domains = init_data[:multiple_domains]
        @preferred_domain = init_data[:preferred_domain]
        @forest = init_data[:forest]

        if init_data[:mount_style].nil? || init_data[:mount_style].is_a?(String)
            raise Jamf::InvalidDataError, "Mount style must be one of #{NETWORK_PROTOCOL.values.join(', ')}." unless NETWORK_PROTOCOL.values.map { |x| x.downcase }.include?(init_data[:mount_style].downcase) || init_data[:mount_style].nil? 
            @mount_style = init_data[:mount_style]
        else
            raise Jamf::InvalidDataError, "Mount style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}," unless NETWORK_PROTOCOL.keys.include? init_data[:mount_style]

            @mount_style = NETWORK_PROTOCOL[init_data[:mount_style]]
        end

        if init_data[:admin_groups].nil?
            # This is needed since we have the ability to add and
            # remove admin groups from this array.
            @admin_groups = []
        elsif init_data[:admin_groups].is_a? String
            @admin_groups = init_data[:admin_groups].split(',')
        else
            @admin_groups = init_data[:admin_groups]
        end
    end

        

    # Public Instance Methods
    #####################################

    # Create mobile account upon login
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def cache_last_user=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "cache_last_user must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @cache_last_user = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Require confirmation before creating a mobile account on the system.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def require_confirmation=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @require_confirmation = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Force local home directory to be placed on the startup disk
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def local_home=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "local_home must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @local_home = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Attempt to derive the network home location using the UNC path stored inside Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def use_unc_path=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "use_unc_path must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @use_unc_path = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The protocol to be use when mounting network home location
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Symbol] One of the keys available in NETWORK_PROTOCOL
    # @see Jamf::DIRECTORYBINDINGTYPE::NETWORK_PROTOCOL
    #
    # @raise [Jamf::InvalidDataError] If the new value provided is not a key inside the NETWORK_PROTOCOL hash.
    #
    # @return [void]
    def mount_style=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "mount_style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}." unless NETWORK_PROTOCOL.keys.include? newvalue

        # Update Value
        @mount_style = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The directory path to the shell user's default shell will be set to upon login.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] Directory path for the specific shell that is wanting to be set.
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def default_shell=(newvalue)

        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @default_shell = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a UID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The UID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def uid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @uid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Specify a specific forest within Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The forest you want to specify
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def forest=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
                newvalue
            end
        
        # Update Value
        @forest = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    # Map specific a User's GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The User's GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def user_gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @user_gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end
        
        # Update Value
        @gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Will this computer be possibly connecting to multiple domains
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a Bool.
    #
    # @return [void]
    def multiple_domains=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "multiple_domains must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @multiple_domains = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # What domain server should be highest priority
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a String.
    #
    # @return [void]
    def preferred_domain=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @preferred_domain = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The AD group which can be considered administrators of a device.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Array <String>]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not an Array.
    #
    # @return [void]
    def admin_groups=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
                
                if newvalue.is_a? Array
                    newvalue.join ","
                else
                    newvalue
                end
            end
            
        # Update Value
        @admin_groups = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Add a specific admin group to the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to add to the admin group list
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def add_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Group \"#{value}\" already is in the admin groups." unless !@admin_groups.include? value

        @admin_groups << value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Remove a specific admin group from the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to remove from the admin groups.
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def remove_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group being removed must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_groups.include? value

        @admin_groups.delete value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Return a REXML Element containing the current state of the DirectoryBindingType
    # object for adding into the XML of the container.
    # 
    # @author Tyler Morgan
    #
    # @return [REXML::Element]
    def type_setting_xml
        type_setting = REXML::Element.new "active_directory"
        type_setting.add_element("cache_last_user").text = @cache_last_user
        type_setting.add_element("require_confirmation").text = @require_confirmation
        type_setting.add_element("local_home").text = @local_home
        type_setting.add_element("use_unc_path").text = @use_unc_path
        type_setting.add_element("mount_style").text = @mount_style.downcase
        type_setting.add_element("default_shell").text = @default_shell
        type_setting.add_element("uid").text = @uid
        type_setting.add_element("user_gid").text = @user_gid
        type_setting.add_element("gid").text = @gid
        type_setting.add_element("multiple_domains").text = @multiple_domains
        type_setting.add_element("preferred_domain").text = @preferred_domain
        type_setting.add_element("admin_groups").text = @admin_groups.join(',').to_s unless @admin_groups.nil?
        type_setting.add_element("forest").text = @forest.to_s

        return type_setting
    end
end

#forestObject

Class for the specific Active Directory DirectoryBinding type stored within the JSS

Attributes TODO: Include default values upon creation

Author:

  • Tyler Morgan



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
211
212
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
430
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
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 60

class ActiveDirectory < DirectoryBindingType
    # Mix-Ins
    #####################################

    # Class Methods
    #####################################

    # Class Constants
    #####################################

    # Attributes
    #####################################
    attr_reader :cache_last_user
    attr_reader :require_confirmation
    attr_reader :local_home
    attr_reader :use_unc_path
    attr_reader :mount_style
    attr_reader :default_shell
    attr_reader :uid
    attr_reader :user_gid
    attr_reader :gid
    attr_reader :multiple_domains
    attr_reader :preferred_domain
    attr_reader :admin_groups
    attr_reader :forest

    # Constructor
    #####################################

    # An initializer for the Active Directory object.
    # 
    # @author Tyler Morgan
    # @see Jamf::DirectoryBinding
    # @see Jamf::DirectoryBindingType
    #
    # @param [Hash] initialize data
    def initialize(init_data)

        # Return without processing anything since there is
        # nothing to process.
        return if init_data.nil?

        # Process provided information
        @cache_last_user = init_data[:cache_last_user]
        @require_confirmation = init_data[:require_confirmation]
        @local_home = init_data[:local_home]
        @use_unc_path = init_data[:use_unc_path]
        @default_shell = init_data[:default_shell]
        @uid = init_data[:uid]
        @user_gid = init_data[:user_gid]
        @gid = init_data[:gid]
        @multiple_domains = init_data[:multiple_domains]
        @preferred_domain = init_data[:preferred_domain]
        @forest = init_data[:forest]

        if init_data[:mount_style].nil? || init_data[:mount_style].is_a?(String)
            raise Jamf::InvalidDataError, "Mount style must be one of #{NETWORK_PROTOCOL.values.join(', ')}." unless NETWORK_PROTOCOL.values.map { |x| x.downcase }.include?(init_data[:mount_style].downcase) || init_data[:mount_style].nil? 
            @mount_style = init_data[:mount_style]
        else
            raise Jamf::InvalidDataError, "Mount style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}," unless NETWORK_PROTOCOL.keys.include? init_data[:mount_style]

            @mount_style = NETWORK_PROTOCOL[init_data[:mount_style]]
        end

        if init_data[:admin_groups].nil?
            # This is needed since we have the ability to add and
            # remove admin groups from this array.
            @admin_groups = []
        elsif init_data[:admin_groups].is_a? String
            @admin_groups = init_data[:admin_groups].split(',')
        else
            @admin_groups = init_data[:admin_groups]
        end
    end

        

    # Public Instance Methods
    #####################################

    # Create mobile account upon login
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def cache_last_user=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "cache_last_user must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @cache_last_user = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Require confirmation before creating a mobile account on the system.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def require_confirmation=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @require_confirmation = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Force local home directory to be placed on the startup disk
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def local_home=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "local_home must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @local_home = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Attempt to derive the network home location using the UNC path stored inside Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def use_unc_path=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "use_unc_path must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @use_unc_path = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The protocol to be use when mounting network home location
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Symbol] One of the keys available in NETWORK_PROTOCOL
    # @see Jamf::DIRECTORYBINDINGTYPE::NETWORK_PROTOCOL
    #
    # @raise [Jamf::InvalidDataError] If the new value provided is not a key inside the NETWORK_PROTOCOL hash.
    #
    # @return [void]
    def mount_style=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "mount_style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}." unless NETWORK_PROTOCOL.keys.include? newvalue

        # Update Value
        @mount_style = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The directory path to the shell user's default shell will be set to upon login.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] Directory path for the specific shell that is wanting to be set.
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def default_shell=(newvalue)

        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @default_shell = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a UID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The UID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def uid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @uid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Specify a specific forest within Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The forest you want to specify
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def forest=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
                newvalue
            end
        
        # Update Value
        @forest = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    # Map specific a User's GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The User's GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def user_gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @user_gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end
        
        # Update Value
        @gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Will this computer be possibly connecting to multiple domains
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a Bool.
    #
    # @return [void]
    def multiple_domains=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "multiple_domains must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @multiple_domains = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # What domain server should be highest priority
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a String.
    #
    # @return [void]
    def preferred_domain=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @preferred_domain = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The AD group which can be considered administrators of a device.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Array <String>]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not an Array.
    #
    # @return [void]
    def admin_groups=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
                
                if newvalue.is_a? Array
                    newvalue.join ","
                else
                    newvalue
                end
            end
            
        # Update Value
        @admin_groups = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Add a specific admin group to the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to add to the admin group list
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def add_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Group \"#{value}\" already is in the admin groups." unless !@admin_groups.include? value

        @admin_groups << value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Remove a specific admin group from the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to remove from the admin groups.
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def remove_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group being removed must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_groups.include? value

        @admin_groups.delete value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Return a REXML Element containing the current state of the DirectoryBindingType
    # object for adding into the XML of the container.
    # 
    # @author Tyler Morgan
    #
    # @return [REXML::Element]
    def type_setting_xml
        type_setting = REXML::Element.new "active_directory"
        type_setting.add_element("cache_last_user").text = @cache_last_user
        type_setting.add_element("require_confirmation").text = @require_confirmation
        type_setting.add_element("local_home").text = @local_home
        type_setting.add_element("use_unc_path").text = @use_unc_path
        type_setting.add_element("mount_style").text = @mount_style.downcase
        type_setting.add_element("default_shell").text = @default_shell
        type_setting.add_element("uid").text = @uid
        type_setting.add_element("user_gid").text = @user_gid
        type_setting.add_element("gid").text = @gid
        type_setting.add_element("multiple_domains").text = @multiple_domains
        type_setting.add_element("preferred_domain").text = @preferred_domain
        type_setting.add_element("admin_groups").text = @admin_groups.join(',').to_s unless @admin_groups.nil?
        type_setting.add_element("forest").text = @forest.to_s

        return type_setting
    end
end

#gidObject

Class for the specific Active Directory DirectoryBinding type stored within the JSS

Attributes TODO: Include default values upon creation

Author:

  • Tyler Morgan



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
211
212
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
430
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
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 60

class ActiveDirectory < DirectoryBindingType
    # Mix-Ins
    #####################################

    # Class Methods
    #####################################

    # Class Constants
    #####################################

    # Attributes
    #####################################
    attr_reader :cache_last_user
    attr_reader :require_confirmation
    attr_reader :local_home
    attr_reader :use_unc_path
    attr_reader :mount_style
    attr_reader :default_shell
    attr_reader :uid
    attr_reader :user_gid
    attr_reader :gid
    attr_reader :multiple_domains
    attr_reader :preferred_domain
    attr_reader :admin_groups
    attr_reader :forest

    # Constructor
    #####################################

    # An initializer for the Active Directory object.
    # 
    # @author Tyler Morgan
    # @see Jamf::DirectoryBinding
    # @see Jamf::DirectoryBindingType
    #
    # @param [Hash] initialize data
    def initialize(init_data)

        # Return without processing anything since there is
        # nothing to process.
        return if init_data.nil?

        # Process provided information
        @cache_last_user = init_data[:cache_last_user]
        @require_confirmation = init_data[:require_confirmation]
        @local_home = init_data[:local_home]
        @use_unc_path = init_data[:use_unc_path]
        @default_shell = init_data[:default_shell]
        @uid = init_data[:uid]
        @user_gid = init_data[:user_gid]
        @gid = init_data[:gid]
        @multiple_domains = init_data[:multiple_domains]
        @preferred_domain = init_data[:preferred_domain]
        @forest = init_data[:forest]

        if init_data[:mount_style].nil? || init_data[:mount_style].is_a?(String)
            raise Jamf::InvalidDataError, "Mount style must be one of #{NETWORK_PROTOCOL.values.join(', ')}." unless NETWORK_PROTOCOL.values.map { |x| x.downcase }.include?(init_data[:mount_style].downcase) || init_data[:mount_style].nil? 
            @mount_style = init_data[:mount_style]
        else
            raise Jamf::InvalidDataError, "Mount style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}," unless NETWORK_PROTOCOL.keys.include? init_data[:mount_style]

            @mount_style = NETWORK_PROTOCOL[init_data[:mount_style]]
        end

        if init_data[:admin_groups].nil?
            # This is needed since we have the ability to add and
            # remove admin groups from this array.
            @admin_groups = []
        elsif init_data[:admin_groups].is_a? String
            @admin_groups = init_data[:admin_groups].split(',')
        else
            @admin_groups = init_data[:admin_groups]
        end
    end

        

    # Public Instance Methods
    #####################################

    # Create mobile account upon login
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def cache_last_user=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "cache_last_user must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @cache_last_user = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Require confirmation before creating a mobile account on the system.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def require_confirmation=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @require_confirmation = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Force local home directory to be placed on the startup disk
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def local_home=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "local_home must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @local_home = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Attempt to derive the network home location using the UNC path stored inside Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def use_unc_path=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "use_unc_path must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @use_unc_path = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The protocol to be use when mounting network home location
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Symbol] One of the keys available in NETWORK_PROTOCOL
    # @see Jamf::DIRECTORYBINDINGTYPE::NETWORK_PROTOCOL
    #
    # @raise [Jamf::InvalidDataError] If the new value provided is not a key inside the NETWORK_PROTOCOL hash.
    #
    # @return [void]
    def mount_style=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "mount_style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}." unless NETWORK_PROTOCOL.keys.include? newvalue

        # Update Value
        @mount_style = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The directory path to the shell user's default shell will be set to upon login.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] Directory path for the specific shell that is wanting to be set.
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def default_shell=(newvalue)

        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @default_shell = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a UID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The UID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def uid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @uid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Specify a specific forest within Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The forest you want to specify
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def forest=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
                newvalue
            end
        
        # Update Value
        @forest = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    # Map specific a User's GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The User's GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def user_gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @user_gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end
        
        # Update Value
        @gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Will this computer be possibly connecting to multiple domains
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a Bool.
    #
    # @return [void]
    def multiple_domains=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "multiple_domains must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @multiple_domains = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # What domain server should be highest priority
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a String.
    #
    # @return [void]
    def preferred_domain=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @preferred_domain = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The AD group which can be considered administrators of a device.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Array <String>]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not an Array.
    #
    # @return [void]
    def admin_groups=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
                
                if newvalue.is_a? Array
                    newvalue.join ","
                else
                    newvalue
                end
            end
            
        # Update Value
        @admin_groups = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Add a specific admin group to the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to add to the admin group list
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def add_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Group \"#{value}\" already is in the admin groups." unless !@admin_groups.include? value

        @admin_groups << value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Remove a specific admin group from the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to remove from the admin groups.
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def remove_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group being removed must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_groups.include? value

        @admin_groups.delete value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Return a REXML Element containing the current state of the DirectoryBindingType
    # object for adding into the XML of the container.
    # 
    # @author Tyler Morgan
    #
    # @return [REXML::Element]
    def type_setting_xml
        type_setting = REXML::Element.new "active_directory"
        type_setting.add_element("cache_last_user").text = @cache_last_user
        type_setting.add_element("require_confirmation").text = @require_confirmation
        type_setting.add_element("local_home").text = @local_home
        type_setting.add_element("use_unc_path").text = @use_unc_path
        type_setting.add_element("mount_style").text = @mount_style.downcase
        type_setting.add_element("default_shell").text = @default_shell
        type_setting.add_element("uid").text = @uid
        type_setting.add_element("user_gid").text = @user_gid
        type_setting.add_element("gid").text = @gid
        type_setting.add_element("multiple_domains").text = @multiple_domains
        type_setting.add_element("preferred_domain").text = @preferred_domain
        type_setting.add_element("admin_groups").text = @admin_groups.join(',').to_s unless @admin_groups.nil?
        type_setting.add_element("forest").text = @forest.to_s

        return type_setting
    end
end

#local_homeObject

Class for the specific Active Directory DirectoryBinding type stored within the JSS

Attributes TODO: Include default values upon creation

Author:

  • Tyler Morgan



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
211
212
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
430
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
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 60

class ActiveDirectory < DirectoryBindingType
    # Mix-Ins
    #####################################

    # Class Methods
    #####################################

    # Class Constants
    #####################################

    # Attributes
    #####################################
    attr_reader :cache_last_user
    attr_reader :require_confirmation
    attr_reader :local_home
    attr_reader :use_unc_path
    attr_reader :mount_style
    attr_reader :default_shell
    attr_reader :uid
    attr_reader :user_gid
    attr_reader :gid
    attr_reader :multiple_domains
    attr_reader :preferred_domain
    attr_reader :admin_groups
    attr_reader :forest

    # Constructor
    #####################################

    # An initializer for the Active Directory object.
    # 
    # @author Tyler Morgan
    # @see Jamf::DirectoryBinding
    # @see Jamf::DirectoryBindingType
    #
    # @param [Hash] initialize data
    def initialize(init_data)

        # Return without processing anything since there is
        # nothing to process.
        return if init_data.nil?

        # Process provided information
        @cache_last_user = init_data[:cache_last_user]
        @require_confirmation = init_data[:require_confirmation]
        @local_home = init_data[:local_home]
        @use_unc_path = init_data[:use_unc_path]
        @default_shell = init_data[:default_shell]
        @uid = init_data[:uid]
        @user_gid = init_data[:user_gid]
        @gid = init_data[:gid]
        @multiple_domains = init_data[:multiple_domains]
        @preferred_domain = init_data[:preferred_domain]
        @forest = init_data[:forest]

        if init_data[:mount_style].nil? || init_data[:mount_style].is_a?(String)
            raise Jamf::InvalidDataError, "Mount style must be one of #{NETWORK_PROTOCOL.values.join(', ')}." unless NETWORK_PROTOCOL.values.map { |x| x.downcase }.include?(init_data[:mount_style].downcase) || init_data[:mount_style].nil? 
            @mount_style = init_data[:mount_style]
        else
            raise Jamf::InvalidDataError, "Mount style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}," unless NETWORK_PROTOCOL.keys.include? init_data[:mount_style]

            @mount_style = NETWORK_PROTOCOL[init_data[:mount_style]]
        end

        if init_data[:admin_groups].nil?
            # This is needed since we have the ability to add and
            # remove admin groups from this array.
            @admin_groups = []
        elsif init_data[:admin_groups].is_a? String
            @admin_groups = init_data[:admin_groups].split(',')
        else
            @admin_groups = init_data[:admin_groups]
        end
    end

        

    # Public Instance Methods
    #####################################

    # Create mobile account upon login
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def cache_last_user=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "cache_last_user must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @cache_last_user = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Require confirmation before creating a mobile account on the system.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def require_confirmation=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @require_confirmation = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Force local home directory to be placed on the startup disk
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def local_home=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "local_home must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @local_home = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Attempt to derive the network home location using the UNC path stored inside Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def use_unc_path=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "use_unc_path must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @use_unc_path = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The protocol to be use when mounting network home location
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Symbol] One of the keys available in NETWORK_PROTOCOL
    # @see Jamf::DIRECTORYBINDINGTYPE::NETWORK_PROTOCOL
    #
    # @raise [Jamf::InvalidDataError] If the new value provided is not a key inside the NETWORK_PROTOCOL hash.
    #
    # @return [void]
    def mount_style=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "mount_style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}." unless NETWORK_PROTOCOL.keys.include? newvalue

        # Update Value
        @mount_style = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The directory path to the shell user's default shell will be set to upon login.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] Directory path for the specific shell that is wanting to be set.
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def default_shell=(newvalue)

        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @default_shell = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a UID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The UID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def uid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @uid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Specify a specific forest within Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The forest you want to specify
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def forest=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
                newvalue
            end
        
        # Update Value
        @forest = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    # Map specific a User's GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The User's GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def user_gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @user_gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end
        
        # Update Value
        @gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Will this computer be possibly connecting to multiple domains
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a Bool.
    #
    # @return [void]
    def multiple_domains=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "multiple_domains must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @multiple_domains = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # What domain server should be highest priority
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a String.
    #
    # @return [void]
    def preferred_domain=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @preferred_domain = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The AD group which can be considered administrators of a device.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Array <String>]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not an Array.
    #
    # @return [void]
    def admin_groups=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
                
                if newvalue.is_a? Array
                    newvalue.join ","
                else
                    newvalue
                end
            end
            
        # Update Value
        @admin_groups = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Add a specific admin group to the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to add to the admin group list
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def add_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Group \"#{value}\" already is in the admin groups." unless !@admin_groups.include? value

        @admin_groups << value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Remove a specific admin group from the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to remove from the admin groups.
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def remove_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group being removed must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_groups.include? value

        @admin_groups.delete value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Return a REXML Element containing the current state of the DirectoryBindingType
    # object for adding into the XML of the container.
    # 
    # @author Tyler Morgan
    #
    # @return [REXML::Element]
    def type_setting_xml
        type_setting = REXML::Element.new "active_directory"
        type_setting.add_element("cache_last_user").text = @cache_last_user
        type_setting.add_element("require_confirmation").text = @require_confirmation
        type_setting.add_element("local_home").text = @local_home
        type_setting.add_element("use_unc_path").text = @use_unc_path
        type_setting.add_element("mount_style").text = @mount_style.downcase
        type_setting.add_element("default_shell").text = @default_shell
        type_setting.add_element("uid").text = @uid
        type_setting.add_element("user_gid").text = @user_gid
        type_setting.add_element("gid").text = @gid
        type_setting.add_element("multiple_domains").text = @multiple_domains
        type_setting.add_element("preferred_domain").text = @preferred_domain
        type_setting.add_element("admin_groups").text = @admin_groups.join(',').to_s unless @admin_groups.nil?
        type_setting.add_element("forest").text = @forest.to_s

        return type_setting
    end
end

#mount_styleObject

Class for the specific Active Directory DirectoryBinding type stored within the JSS

Attributes TODO: Include default values upon creation

Author:

  • Tyler Morgan



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
211
212
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
430
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
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 60

class ActiveDirectory < DirectoryBindingType
    # Mix-Ins
    #####################################

    # Class Methods
    #####################################

    # Class Constants
    #####################################

    # Attributes
    #####################################
    attr_reader :cache_last_user
    attr_reader :require_confirmation
    attr_reader :local_home
    attr_reader :use_unc_path
    attr_reader :mount_style
    attr_reader :default_shell
    attr_reader :uid
    attr_reader :user_gid
    attr_reader :gid
    attr_reader :multiple_domains
    attr_reader :preferred_domain
    attr_reader :admin_groups
    attr_reader :forest

    # Constructor
    #####################################

    # An initializer for the Active Directory object.
    # 
    # @author Tyler Morgan
    # @see Jamf::DirectoryBinding
    # @see Jamf::DirectoryBindingType
    #
    # @param [Hash] initialize data
    def initialize(init_data)

        # Return without processing anything since there is
        # nothing to process.
        return if init_data.nil?

        # Process provided information
        @cache_last_user = init_data[:cache_last_user]
        @require_confirmation = init_data[:require_confirmation]
        @local_home = init_data[:local_home]
        @use_unc_path = init_data[:use_unc_path]
        @default_shell = init_data[:default_shell]
        @uid = init_data[:uid]
        @user_gid = init_data[:user_gid]
        @gid = init_data[:gid]
        @multiple_domains = init_data[:multiple_domains]
        @preferred_domain = init_data[:preferred_domain]
        @forest = init_data[:forest]

        if init_data[:mount_style].nil? || init_data[:mount_style].is_a?(String)
            raise Jamf::InvalidDataError, "Mount style must be one of #{NETWORK_PROTOCOL.values.join(', ')}." unless NETWORK_PROTOCOL.values.map { |x| x.downcase }.include?(init_data[:mount_style].downcase) || init_data[:mount_style].nil? 
            @mount_style = init_data[:mount_style]
        else
            raise Jamf::InvalidDataError, "Mount style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}," unless NETWORK_PROTOCOL.keys.include? init_data[:mount_style]

            @mount_style = NETWORK_PROTOCOL[init_data[:mount_style]]
        end

        if init_data[:admin_groups].nil?
            # This is needed since we have the ability to add and
            # remove admin groups from this array.
            @admin_groups = []
        elsif init_data[:admin_groups].is_a? String
            @admin_groups = init_data[:admin_groups].split(',')
        else
            @admin_groups = init_data[:admin_groups]
        end
    end

        

    # Public Instance Methods
    #####################################

    # Create mobile account upon login
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def cache_last_user=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "cache_last_user must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @cache_last_user = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Require confirmation before creating a mobile account on the system.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def require_confirmation=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @require_confirmation = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Force local home directory to be placed on the startup disk
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def local_home=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "local_home must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @local_home = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Attempt to derive the network home location using the UNC path stored inside Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def use_unc_path=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "use_unc_path must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @use_unc_path = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The protocol to be use when mounting network home location
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Symbol] One of the keys available in NETWORK_PROTOCOL
    # @see Jamf::DIRECTORYBINDINGTYPE::NETWORK_PROTOCOL
    #
    # @raise [Jamf::InvalidDataError] If the new value provided is not a key inside the NETWORK_PROTOCOL hash.
    #
    # @return [void]
    def mount_style=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "mount_style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}." unless NETWORK_PROTOCOL.keys.include? newvalue

        # Update Value
        @mount_style = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The directory path to the shell user's default shell will be set to upon login.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] Directory path for the specific shell that is wanting to be set.
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def default_shell=(newvalue)

        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @default_shell = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a UID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The UID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def uid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @uid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Specify a specific forest within Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The forest you want to specify
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def forest=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
                newvalue
            end
        
        # Update Value
        @forest = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    # Map specific a User's GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The User's GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def user_gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @user_gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end
        
        # Update Value
        @gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Will this computer be possibly connecting to multiple domains
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a Bool.
    #
    # @return [void]
    def multiple_domains=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "multiple_domains must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @multiple_domains = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # What domain server should be highest priority
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a String.
    #
    # @return [void]
    def preferred_domain=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @preferred_domain = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The AD group which can be considered administrators of a device.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Array <String>]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not an Array.
    #
    # @return [void]
    def admin_groups=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
                
                if newvalue.is_a? Array
                    newvalue.join ","
                else
                    newvalue
                end
            end
            
        # Update Value
        @admin_groups = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Add a specific admin group to the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to add to the admin group list
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def add_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Group \"#{value}\" already is in the admin groups." unless !@admin_groups.include? value

        @admin_groups << value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Remove a specific admin group from the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to remove from the admin groups.
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def remove_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group being removed must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_groups.include? value

        @admin_groups.delete value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Return a REXML Element containing the current state of the DirectoryBindingType
    # object for adding into the XML of the container.
    # 
    # @author Tyler Morgan
    #
    # @return [REXML::Element]
    def type_setting_xml
        type_setting = REXML::Element.new "active_directory"
        type_setting.add_element("cache_last_user").text = @cache_last_user
        type_setting.add_element("require_confirmation").text = @require_confirmation
        type_setting.add_element("local_home").text = @local_home
        type_setting.add_element("use_unc_path").text = @use_unc_path
        type_setting.add_element("mount_style").text = @mount_style.downcase
        type_setting.add_element("default_shell").text = @default_shell
        type_setting.add_element("uid").text = @uid
        type_setting.add_element("user_gid").text = @user_gid
        type_setting.add_element("gid").text = @gid
        type_setting.add_element("multiple_domains").text = @multiple_domains
        type_setting.add_element("preferred_domain").text = @preferred_domain
        type_setting.add_element("admin_groups").text = @admin_groups.join(',').to_s unless @admin_groups.nil?
        type_setting.add_element("forest").text = @forest.to_s

        return type_setting
    end
end

#multiple_domainsObject

Class for the specific Active Directory DirectoryBinding type stored within the JSS

Attributes TODO: Include default values upon creation

Author:

  • Tyler Morgan



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
211
212
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
430
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
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 60

class ActiveDirectory < DirectoryBindingType
    # Mix-Ins
    #####################################

    # Class Methods
    #####################################

    # Class Constants
    #####################################

    # Attributes
    #####################################
    attr_reader :cache_last_user
    attr_reader :require_confirmation
    attr_reader :local_home
    attr_reader :use_unc_path
    attr_reader :mount_style
    attr_reader :default_shell
    attr_reader :uid
    attr_reader :user_gid
    attr_reader :gid
    attr_reader :multiple_domains
    attr_reader :preferred_domain
    attr_reader :admin_groups
    attr_reader :forest

    # Constructor
    #####################################

    # An initializer for the Active Directory object.
    # 
    # @author Tyler Morgan
    # @see Jamf::DirectoryBinding
    # @see Jamf::DirectoryBindingType
    #
    # @param [Hash] initialize data
    def initialize(init_data)

        # Return without processing anything since there is
        # nothing to process.
        return if init_data.nil?

        # Process provided information
        @cache_last_user = init_data[:cache_last_user]
        @require_confirmation = init_data[:require_confirmation]
        @local_home = init_data[:local_home]
        @use_unc_path = init_data[:use_unc_path]
        @default_shell = init_data[:default_shell]
        @uid = init_data[:uid]
        @user_gid = init_data[:user_gid]
        @gid = init_data[:gid]
        @multiple_domains = init_data[:multiple_domains]
        @preferred_domain = init_data[:preferred_domain]
        @forest = init_data[:forest]

        if init_data[:mount_style].nil? || init_data[:mount_style].is_a?(String)
            raise Jamf::InvalidDataError, "Mount style must be one of #{NETWORK_PROTOCOL.values.join(', ')}." unless NETWORK_PROTOCOL.values.map { |x| x.downcase }.include?(init_data[:mount_style].downcase) || init_data[:mount_style].nil? 
            @mount_style = init_data[:mount_style]
        else
            raise Jamf::InvalidDataError, "Mount style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}," unless NETWORK_PROTOCOL.keys.include? init_data[:mount_style]

            @mount_style = NETWORK_PROTOCOL[init_data[:mount_style]]
        end

        if init_data[:admin_groups].nil?
            # This is needed since we have the ability to add and
            # remove admin groups from this array.
            @admin_groups = []
        elsif init_data[:admin_groups].is_a? String
            @admin_groups = init_data[:admin_groups].split(',')
        else
            @admin_groups = init_data[:admin_groups]
        end
    end

        

    # Public Instance Methods
    #####################################

    # Create mobile account upon login
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def cache_last_user=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "cache_last_user must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @cache_last_user = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Require confirmation before creating a mobile account on the system.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def require_confirmation=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @require_confirmation = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Force local home directory to be placed on the startup disk
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def local_home=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "local_home must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @local_home = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Attempt to derive the network home location using the UNC path stored inside Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def use_unc_path=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "use_unc_path must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @use_unc_path = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The protocol to be use when mounting network home location
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Symbol] One of the keys available in NETWORK_PROTOCOL
    # @see Jamf::DIRECTORYBINDINGTYPE::NETWORK_PROTOCOL
    #
    # @raise [Jamf::InvalidDataError] If the new value provided is not a key inside the NETWORK_PROTOCOL hash.
    #
    # @return [void]
    def mount_style=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "mount_style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}." unless NETWORK_PROTOCOL.keys.include? newvalue

        # Update Value
        @mount_style = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The directory path to the shell user's default shell will be set to upon login.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] Directory path for the specific shell that is wanting to be set.
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def default_shell=(newvalue)

        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @default_shell = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a UID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The UID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def uid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @uid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Specify a specific forest within Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The forest you want to specify
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def forest=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
                newvalue
            end
        
        # Update Value
        @forest = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    # Map specific a User's GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The User's GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def user_gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @user_gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end
        
        # Update Value
        @gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Will this computer be possibly connecting to multiple domains
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a Bool.
    #
    # @return [void]
    def multiple_domains=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "multiple_domains must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @multiple_domains = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # What domain server should be highest priority
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a String.
    #
    # @return [void]
    def preferred_domain=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @preferred_domain = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The AD group which can be considered administrators of a device.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Array <String>]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not an Array.
    #
    # @return [void]
    def admin_groups=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
                
                if newvalue.is_a? Array
                    newvalue.join ","
                else
                    newvalue
                end
            end
            
        # Update Value
        @admin_groups = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Add a specific admin group to the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to add to the admin group list
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def add_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Group \"#{value}\" already is in the admin groups." unless !@admin_groups.include? value

        @admin_groups << value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Remove a specific admin group from the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to remove from the admin groups.
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def remove_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group being removed must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_groups.include? value

        @admin_groups.delete value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Return a REXML Element containing the current state of the DirectoryBindingType
    # object for adding into the XML of the container.
    # 
    # @author Tyler Morgan
    #
    # @return [REXML::Element]
    def type_setting_xml
        type_setting = REXML::Element.new "active_directory"
        type_setting.add_element("cache_last_user").text = @cache_last_user
        type_setting.add_element("require_confirmation").text = @require_confirmation
        type_setting.add_element("local_home").text = @local_home
        type_setting.add_element("use_unc_path").text = @use_unc_path
        type_setting.add_element("mount_style").text = @mount_style.downcase
        type_setting.add_element("default_shell").text = @default_shell
        type_setting.add_element("uid").text = @uid
        type_setting.add_element("user_gid").text = @user_gid
        type_setting.add_element("gid").text = @gid
        type_setting.add_element("multiple_domains").text = @multiple_domains
        type_setting.add_element("preferred_domain").text = @preferred_domain
        type_setting.add_element("admin_groups").text = @admin_groups.join(',').to_s unless @admin_groups.nil?
        type_setting.add_element("forest").text = @forest.to_s

        return type_setting
    end
end

#preferred_domainObject

Class for the specific Active Directory DirectoryBinding type stored within the JSS

Attributes TODO: Include default values upon creation

Author:

  • Tyler Morgan



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
211
212
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
430
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
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 60

class ActiveDirectory < DirectoryBindingType
    # Mix-Ins
    #####################################

    # Class Methods
    #####################################

    # Class Constants
    #####################################

    # Attributes
    #####################################
    attr_reader :cache_last_user
    attr_reader :require_confirmation
    attr_reader :local_home
    attr_reader :use_unc_path
    attr_reader :mount_style
    attr_reader :default_shell
    attr_reader :uid
    attr_reader :user_gid
    attr_reader :gid
    attr_reader :multiple_domains
    attr_reader :preferred_domain
    attr_reader :admin_groups
    attr_reader :forest

    # Constructor
    #####################################

    # An initializer for the Active Directory object.
    # 
    # @author Tyler Morgan
    # @see Jamf::DirectoryBinding
    # @see Jamf::DirectoryBindingType
    #
    # @param [Hash] initialize data
    def initialize(init_data)

        # Return without processing anything since there is
        # nothing to process.
        return if init_data.nil?

        # Process provided information
        @cache_last_user = init_data[:cache_last_user]
        @require_confirmation = init_data[:require_confirmation]
        @local_home = init_data[:local_home]
        @use_unc_path = init_data[:use_unc_path]
        @default_shell = init_data[:default_shell]
        @uid = init_data[:uid]
        @user_gid = init_data[:user_gid]
        @gid = init_data[:gid]
        @multiple_domains = init_data[:multiple_domains]
        @preferred_domain = init_data[:preferred_domain]
        @forest = init_data[:forest]

        if init_data[:mount_style].nil? || init_data[:mount_style].is_a?(String)
            raise Jamf::InvalidDataError, "Mount style must be one of #{NETWORK_PROTOCOL.values.join(', ')}." unless NETWORK_PROTOCOL.values.map { |x| x.downcase }.include?(init_data[:mount_style].downcase) || init_data[:mount_style].nil? 
            @mount_style = init_data[:mount_style]
        else
            raise Jamf::InvalidDataError, "Mount style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}," unless NETWORK_PROTOCOL.keys.include? init_data[:mount_style]

            @mount_style = NETWORK_PROTOCOL[init_data[:mount_style]]
        end

        if init_data[:admin_groups].nil?
            # This is needed since we have the ability to add and
            # remove admin groups from this array.
            @admin_groups = []
        elsif init_data[:admin_groups].is_a? String
            @admin_groups = init_data[:admin_groups].split(',')
        else
            @admin_groups = init_data[:admin_groups]
        end
    end

        

    # Public Instance Methods
    #####################################

    # Create mobile account upon login
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def cache_last_user=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "cache_last_user must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @cache_last_user = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Require confirmation before creating a mobile account on the system.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def require_confirmation=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @require_confirmation = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Force local home directory to be placed on the startup disk
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def local_home=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "local_home must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @local_home = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Attempt to derive the network home location using the UNC path stored inside Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def use_unc_path=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "use_unc_path must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @use_unc_path = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The protocol to be use when mounting network home location
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Symbol] One of the keys available in NETWORK_PROTOCOL
    # @see Jamf::DIRECTORYBINDINGTYPE::NETWORK_PROTOCOL
    #
    # @raise [Jamf::InvalidDataError] If the new value provided is not a key inside the NETWORK_PROTOCOL hash.
    #
    # @return [void]
    def mount_style=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "mount_style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}." unless NETWORK_PROTOCOL.keys.include? newvalue

        # Update Value
        @mount_style = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The directory path to the shell user's default shell will be set to upon login.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] Directory path for the specific shell that is wanting to be set.
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def default_shell=(newvalue)

        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @default_shell = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a UID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The UID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def uid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @uid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Specify a specific forest within Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The forest you want to specify
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def forest=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
                newvalue
            end
        
        # Update Value
        @forest = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    # Map specific a User's GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The User's GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def user_gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @user_gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end
        
        # Update Value
        @gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Will this computer be possibly connecting to multiple domains
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a Bool.
    #
    # @return [void]
    def multiple_domains=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "multiple_domains must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @multiple_domains = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # What domain server should be highest priority
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a String.
    #
    # @return [void]
    def preferred_domain=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @preferred_domain = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The AD group which can be considered administrators of a device.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Array <String>]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not an Array.
    #
    # @return [void]
    def admin_groups=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
                
                if newvalue.is_a? Array
                    newvalue.join ","
                else
                    newvalue
                end
            end
            
        # Update Value
        @admin_groups = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Add a specific admin group to the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to add to the admin group list
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def add_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Group \"#{value}\" already is in the admin groups." unless !@admin_groups.include? value

        @admin_groups << value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Remove a specific admin group from the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to remove from the admin groups.
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def remove_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group being removed must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_groups.include? value

        @admin_groups.delete value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Return a REXML Element containing the current state of the DirectoryBindingType
    # object for adding into the XML of the container.
    # 
    # @author Tyler Morgan
    #
    # @return [REXML::Element]
    def type_setting_xml
        type_setting = REXML::Element.new "active_directory"
        type_setting.add_element("cache_last_user").text = @cache_last_user
        type_setting.add_element("require_confirmation").text = @require_confirmation
        type_setting.add_element("local_home").text = @local_home
        type_setting.add_element("use_unc_path").text = @use_unc_path
        type_setting.add_element("mount_style").text = @mount_style.downcase
        type_setting.add_element("default_shell").text = @default_shell
        type_setting.add_element("uid").text = @uid
        type_setting.add_element("user_gid").text = @user_gid
        type_setting.add_element("gid").text = @gid
        type_setting.add_element("multiple_domains").text = @multiple_domains
        type_setting.add_element("preferred_domain").text = @preferred_domain
        type_setting.add_element("admin_groups").text = @admin_groups.join(',').to_s unless @admin_groups.nil?
        type_setting.add_element("forest").text = @forest.to_s

        return type_setting
    end
end

#require_confirmationObject

Class for the specific Active Directory DirectoryBinding type stored within the JSS

Attributes TODO: Include default values upon creation

Author:

  • Tyler Morgan



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
211
212
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
430
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
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 60

class ActiveDirectory < DirectoryBindingType
    # Mix-Ins
    #####################################

    # Class Methods
    #####################################

    # Class Constants
    #####################################

    # Attributes
    #####################################
    attr_reader :cache_last_user
    attr_reader :require_confirmation
    attr_reader :local_home
    attr_reader :use_unc_path
    attr_reader :mount_style
    attr_reader :default_shell
    attr_reader :uid
    attr_reader :user_gid
    attr_reader :gid
    attr_reader :multiple_domains
    attr_reader :preferred_domain
    attr_reader :admin_groups
    attr_reader :forest

    # Constructor
    #####################################

    # An initializer for the Active Directory object.
    # 
    # @author Tyler Morgan
    # @see Jamf::DirectoryBinding
    # @see Jamf::DirectoryBindingType
    #
    # @param [Hash] initialize data
    def initialize(init_data)

        # Return without processing anything since there is
        # nothing to process.
        return if init_data.nil?

        # Process provided information
        @cache_last_user = init_data[:cache_last_user]
        @require_confirmation = init_data[:require_confirmation]
        @local_home = init_data[:local_home]
        @use_unc_path = init_data[:use_unc_path]
        @default_shell = init_data[:default_shell]
        @uid = init_data[:uid]
        @user_gid = init_data[:user_gid]
        @gid = init_data[:gid]
        @multiple_domains = init_data[:multiple_domains]
        @preferred_domain = init_data[:preferred_domain]
        @forest = init_data[:forest]

        if init_data[:mount_style].nil? || init_data[:mount_style].is_a?(String)
            raise Jamf::InvalidDataError, "Mount style must be one of #{NETWORK_PROTOCOL.values.join(', ')}." unless NETWORK_PROTOCOL.values.map { |x| x.downcase }.include?(init_data[:mount_style].downcase) || init_data[:mount_style].nil? 
            @mount_style = init_data[:mount_style]
        else
            raise Jamf::InvalidDataError, "Mount style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}," unless NETWORK_PROTOCOL.keys.include? init_data[:mount_style]

            @mount_style = NETWORK_PROTOCOL[init_data[:mount_style]]
        end

        if init_data[:admin_groups].nil?
            # This is needed since we have the ability to add and
            # remove admin groups from this array.
            @admin_groups = []
        elsif init_data[:admin_groups].is_a? String
            @admin_groups = init_data[:admin_groups].split(',')
        else
            @admin_groups = init_data[:admin_groups]
        end
    end

        

    # Public Instance Methods
    #####################################

    # Create mobile account upon login
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def cache_last_user=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "cache_last_user must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @cache_last_user = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Require confirmation before creating a mobile account on the system.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def require_confirmation=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @require_confirmation = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Force local home directory to be placed on the startup disk
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def local_home=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "local_home must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @local_home = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Attempt to derive the network home location using the UNC path stored inside Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def use_unc_path=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "use_unc_path must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @use_unc_path = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The protocol to be use when mounting network home location
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Symbol] One of the keys available in NETWORK_PROTOCOL
    # @see Jamf::DIRECTORYBINDINGTYPE::NETWORK_PROTOCOL
    #
    # @raise [Jamf::InvalidDataError] If the new value provided is not a key inside the NETWORK_PROTOCOL hash.
    #
    # @return [void]
    def mount_style=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "mount_style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}." unless NETWORK_PROTOCOL.keys.include? newvalue

        # Update Value
        @mount_style = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The directory path to the shell user's default shell will be set to upon login.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] Directory path for the specific shell that is wanting to be set.
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def default_shell=(newvalue)

        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @default_shell = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a UID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The UID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def uid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @uid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Specify a specific forest within Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The forest you want to specify
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def forest=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
                newvalue
            end
        
        # Update Value
        @forest = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    # Map specific a User's GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The User's GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def user_gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @user_gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end
        
        # Update Value
        @gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Will this computer be possibly connecting to multiple domains
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a Bool.
    #
    # @return [void]
    def multiple_domains=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "multiple_domains must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @multiple_domains = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # What domain server should be highest priority
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a String.
    #
    # @return [void]
    def preferred_domain=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @preferred_domain = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The AD group which can be considered administrators of a device.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Array <String>]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not an Array.
    #
    # @return [void]
    def admin_groups=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
                
                if newvalue.is_a? Array
                    newvalue.join ","
                else
                    newvalue
                end
            end
            
        # Update Value
        @admin_groups = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Add a specific admin group to the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to add to the admin group list
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def add_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Group \"#{value}\" already is in the admin groups." unless !@admin_groups.include? value

        @admin_groups << value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Remove a specific admin group from the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to remove from the admin groups.
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def remove_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group being removed must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_groups.include? value

        @admin_groups.delete value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Return a REXML Element containing the current state of the DirectoryBindingType
    # object for adding into the XML of the container.
    # 
    # @author Tyler Morgan
    #
    # @return [REXML::Element]
    def type_setting_xml
        type_setting = REXML::Element.new "active_directory"
        type_setting.add_element("cache_last_user").text = @cache_last_user
        type_setting.add_element("require_confirmation").text = @require_confirmation
        type_setting.add_element("local_home").text = @local_home
        type_setting.add_element("use_unc_path").text = @use_unc_path
        type_setting.add_element("mount_style").text = @mount_style.downcase
        type_setting.add_element("default_shell").text = @default_shell
        type_setting.add_element("uid").text = @uid
        type_setting.add_element("user_gid").text = @user_gid
        type_setting.add_element("gid").text = @gid
        type_setting.add_element("multiple_domains").text = @multiple_domains
        type_setting.add_element("preferred_domain").text = @preferred_domain
        type_setting.add_element("admin_groups").text = @admin_groups.join(',').to_s unless @admin_groups.nil?
        type_setting.add_element("forest").text = @forest.to_s

        return type_setting
    end
end

#uidObject

Class for the specific Active Directory DirectoryBinding type stored within the JSS

Attributes TODO: Include default values upon creation

Author:

  • Tyler Morgan



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
211
212
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
430
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
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 60

class ActiveDirectory < DirectoryBindingType
    # Mix-Ins
    #####################################

    # Class Methods
    #####################################

    # Class Constants
    #####################################

    # Attributes
    #####################################
    attr_reader :cache_last_user
    attr_reader :require_confirmation
    attr_reader :local_home
    attr_reader :use_unc_path
    attr_reader :mount_style
    attr_reader :default_shell
    attr_reader :uid
    attr_reader :user_gid
    attr_reader :gid
    attr_reader :multiple_domains
    attr_reader :preferred_domain
    attr_reader :admin_groups
    attr_reader :forest

    # Constructor
    #####################################

    # An initializer for the Active Directory object.
    # 
    # @author Tyler Morgan
    # @see Jamf::DirectoryBinding
    # @see Jamf::DirectoryBindingType
    #
    # @param [Hash] initialize data
    def initialize(init_data)

        # Return without processing anything since there is
        # nothing to process.
        return if init_data.nil?

        # Process provided information
        @cache_last_user = init_data[:cache_last_user]
        @require_confirmation = init_data[:require_confirmation]
        @local_home = init_data[:local_home]
        @use_unc_path = init_data[:use_unc_path]
        @default_shell = init_data[:default_shell]
        @uid = init_data[:uid]
        @user_gid = init_data[:user_gid]
        @gid = init_data[:gid]
        @multiple_domains = init_data[:multiple_domains]
        @preferred_domain = init_data[:preferred_domain]
        @forest = init_data[:forest]

        if init_data[:mount_style].nil? || init_data[:mount_style].is_a?(String)
            raise Jamf::InvalidDataError, "Mount style must be one of #{NETWORK_PROTOCOL.values.join(', ')}." unless NETWORK_PROTOCOL.values.map { |x| x.downcase }.include?(init_data[:mount_style].downcase) || init_data[:mount_style].nil? 
            @mount_style = init_data[:mount_style]
        else
            raise Jamf::InvalidDataError, "Mount style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}," unless NETWORK_PROTOCOL.keys.include? init_data[:mount_style]

            @mount_style = NETWORK_PROTOCOL[init_data[:mount_style]]
        end

        if init_data[:admin_groups].nil?
            # This is needed since we have the ability to add and
            # remove admin groups from this array.
            @admin_groups = []
        elsif init_data[:admin_groups].is_a? String
            @admin_groups = init_data[:admin_groups].split(',')
        else
            @admin_groups = init_data[:admin_groups]
        end
    end

        

    # Public Instance Methods
    #####################################

    # Create mobile account upon login
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def cache_last_user=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "cache_last_user must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @cache_last_user = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Require confirmation before creating a mobile account on the system.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def require_confirmation=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @require_confirmation = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Force local home directory to be placed on the startup disk
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def local_home=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "local_home must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @local_home = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Attempt to derive the network home location using the UNC path stored inside Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def use_unc_path=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "use_unc_path must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @use_unc_path = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The protocol to be use when mounting network home location
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Symbol] One of the keys available in NETWORK_PROTOCOL
    # @see Jamf::DIRECTORYBINDINGTYPE::NETWORK_PROTOCOL
    #
    # @raise [Jamf::InvalidDataError] If the new value provided is not a key inside the NETWORK_PROTOCOL hash.
    #
    # @return [void]
    def mount_style=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "mount_style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}." unless NETWORK_PROTOCOL.keys.include? newvalue

        # Update Value
        @mount_style = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The directory path to the shell user's default shell will be set to upon login.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] Directory path for the specific shell that is wanting to be set.
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def default_shell=(newvalue)

        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @default_shell = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a UID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The UID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def uid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @uid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Specify a specific forest within Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The forest you want to specify
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def forest=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
                newvalue
            end
        
        # Update Value
        @forest = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    # Map specific a User's GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The User's GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def user_gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @user_gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end
        
        # Update Value
        @gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Will this computer be possibly connecting to multiple domains
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a Bool.
    #
    # @return [void]
    def multiple_domains=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "multiple_domains must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @multiple_domains = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # What domain server should be highest priority
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a String.
    #
    # @return [void]
    def preferred_domain=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @preferred_domain = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The AD group which can be considered administrators of a device.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Array <String>]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not an Array.
    #
    # @return [void]
    def admin_groups=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
                
                if newvalue.is_a? Array
                    newvalue.join ","
                else
                    newvalue
                end
            end
            
        # Update Value
        @admin_groups = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Add a specific admin group to the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to add to the admin group list
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def add_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Group \"#{value}\" already is in the admin groups." unless !@admin_groups.include? value

        @admin_groups << value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Remove a specific admin group from the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to remove from the admin groups.
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def remove_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group being removed must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_groups.include? value

        @admin_groups.delete value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Return a REXML Element containing the current state of the DirectoryBindingType
    # object for adding into the XML of the container.
    # 
    # @author Tyler Morgan
    #
    # @return [REXML::Element]
    def type_setting_xml
        type_setting = REXML::Element.new "active_directory"
        type_setting.add_element("cache_last_user").text = @cache_last_user
        type_setting.add_element("require_confirmation").text = @require_confirmation
        type_setting.add_element("local_home").text = @local_home
        type_setting.add_element("use_unc_path").text = @use_unc_path
        type_setting.add_element("mount_style").text = @mount_style.downcase
        type_setting.add_element("default_shell").text = @default_shell
        type_setting.add_element("uid").text = @uid
        type_setting.add_element("user_gid").text = @user_gid
        type_setting.add_element("gid").text = @gid
        type_setting.add_element("multiple_domains").text = @multiple_domains
        type_setting.add_element("preferred_domain").text = @preferred_domain
        type_setting.add_element("admin_groups").text = @admin_groups.join(',').to_s unless @admin_groups.nil?
        type_setting.add_element("forest").text = @forest.to_s

        return type_setting
    end
end

#use_unc_pathObject

Class for the specific Active Directory DirectoryBinding type stored within the JSS

Attributes TODO: Include default values upon creation

Author:

  • Tyler Morgan



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
211
212
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
430
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
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 60

class ActiveDirectory < DirectoryBindingType
    # Mix-Ins
    #####################################

    # Class Methods
    #####################################

    # Class Constants
    #####################################

    # Attributes
    #####################################
    attr_reader :cache_last_user
    attr_reader :require_confirmation
    attr_reader :local_home
    attr_reader :use_unc_path
    attr_reader :mount_style
    attr_reader :default_shell
    attr_reader :uid
    attr_reader :user_gid
    attr_reader :gid
    attr_reader :multiple_domains
    attr_reader :preferred_domain
    attr_reader :admin_groups
    attr_reader :forest

    # Constructor
    #####################################

    # An initializer for the Active Directory object.
    # 
    # @author Tyler Morgan
    # @see Jamf::DirectoryBinding
    # @see Jamf::DirectoryBindingType
    #
    # @param [Hash] initialize data
    def initialize(init_data)

        # Return without processing anything since there is
        # nothing to process.
        return if init_data.nil?

        # Process provided information
        @cache_last_user = init_data[:cache_last_user]
        @require_confirmation = init_data[:require_confirmation]
        @local_home = init_data[:local_home]
        @use_unc_path = init_data[:use_unc_path]
        @default_shell = init_data[:default_shell]
        @uid = init_data[:uid]
        @user_gid = init_data[:user_gid]
        @gid = init_data[:gid]
        @multiple_domains = init_data[:multiple_domains]
        @preferred_domain = init_data[:preferred_domain]
        @forest = init_data[:forest]

        if init_data[:mount_style].nil? || init_data[:mount_style].is_a?(String)
            raise Jamf::InvalidDataError, "Mount style must be one of #{NETWORK_PROTOCOL.values.join(', ')}." unless NETWORK_PROTOCOL.values.map { |x| x.downcase }.include?(init_data[:mount_style].downcase) || init_data[:mount_style].nil? 
            @mount_style = init_data[:mount_style]
        else
            raise Jamf::InvalidDataError, "Mount style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}," unless NETWORK_PROTOCOL.keys.include? init_data[:mount_style]

            @mount_style = NETWORK_PROTOCOL[init_data[:mount_style]]
        end

        if init_data[:admin_groups].nil?
            # This is needed since we have the ability to add and
            # remove admin groups from this array.
            @admin_groups = []
        elsif init_data[:admin_groups].is_a? String
            @admin_groups = init_data[:admin_groups].split(',')
        else
            @admin_groups = init_data[:admin_groups]
        end
    end

        

    # Public Instance Methods
    #####################################

    # Create mobile account upon login
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def cache_last_user=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "cache_last_user must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @cache_last_user = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Require confirmation before creating a mobile account on the system.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def require_confirmation=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @require_confirmation = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Force local home directory to be placed on the startup disk
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def local_home=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "local_home must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @local_home = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Attempt to derive the network home location using the UNC path stored inside Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def use_unc_path=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "use_unc_path must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @use_unc_path = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The protocol to be use when mounting network home location
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Symbol] One of the keys available in NETWORK_PROTOCOL
    # @see Jamf::DIRECTORYBINDINGTYPE::NETWORK_PROTOCOL
    #
    # @raise [Jamf::InvalidDataError] If the new value provided is not a key inside the NETWORK_PROTOCOL hash.
    #
    # @return [void]
    def mount_style=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "mount_style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}." unless NETWORK_PROTOCOL.keys.include? newvalue

        # Update Value
        @mount_style = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The directory path to the shell user's default shell will be set to upon login.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] Directory path for the specific shell that is wanting to be set.
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def default_shell=(newvalue)

        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @default_shell = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a UID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The UID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def uid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @uid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Specify a specific forest within Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The forest you want to specify
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def forest=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
                newvalue
            end
        
        # Update Value
        @forest = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    # Map specific a User's GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The User's GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def user_gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @user_gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end
        
        # Update Value
        @gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Will this computer be possibly connecting to multiple domains
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a Bool.
    #
    # @return [void]
    def multiple_domains=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "multiple_domains must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @multiple_domains = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # What domain server should be highest priority
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a String.
    #
    # @return [void]
    def preferred_domain=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @preferred_domain = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The AD group which can be considered administrators of a device.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Array <String>]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not an Array.
    #
    # @return [void]
    def admin_groups=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
                
                if newvalue.is_a? Array
                    newvalue.join ","
                else
                    newvalue
                end
            end
            
        # Update Value
        @admin_groups = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Add a specific admin group to the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to add to the admin group list
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def add_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Group \"#{value}\" already is in the admin groups." unless !@admin_groups.include? value

        @admin_groups << value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Remove a specific admin group from the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to remove from the admin groups.
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def remove_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group being removed must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_groups.include? value

        @admin_groups.delete value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Return a REXML Element containing the current state of the DirectoryBindingType
    # object for adding into the XML of the container.
    # 
    # @author Tyler Morgan
    #
    # @return [REXML::Element]
    def type_setting_xml
        type_setting = REXML::Element.new "active_directory"
        type_setting.add_element("cache_last_user").text = @cache_last_user
        type_setting.add_element("require_confirmation").text = @require_confirmation
        type_setting.add_element("local_home").text = @local_home
        type_setting.add_element("use_unc_path").text = @use_unc_path
        type_setting.add_element("mount_style").text = @mount_style.downcase
        type_setting.add_element("default_shell").text = @default_shell
        type_setting.add_element("uid").text = @uid
        type_setting.add_element("user_gid").text = @user_gid
        type_setting.add_element("gid").text = @gid
        type_setting.add_element("multiple_domains").text = @multiple_domains
        type_setting.add_element("preferred_domain").text = @preferred_domain
        type_setting.add_element("admin_groups").text = @admin_groups.join(',').to_s unless @admin_groups.nil?
        type_setting.add_element("forest").text = @forest.to_s

        return type_setting
    end
end

#user_gidObject

Class for the specific Active Directory DirectoryBinding type stored within the JSS

Attributes TODO: Include default values upon creation

Author:

  • Tyler Morgan



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
211
212
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
430
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
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 60

class ActiveDirectory < DirectoryBindingType
    # Mix-Ins
    #####################################

    # Class Methods
    #####################################

    # Class Constants
    #####################################

    # Attributes
    #####################################
    attr_reader :cache_last_user
    attr_reader :require_confirmation
    attr_reader :local_home
    attr_reader :use_unc_path
    attr_reader :mount_style
    attr_reader :default_shell
    attr_reader :uid
    attr_reader :user_gid
    attr_reader :gid
    attr_reader :multiple_domains
    attr_reader :preferred_domain
    attr_reader :admin_groups
    attr_reader :forest

    # Constructor
    #####################################

    # An initializer for the Active Directory object.
    # 
    # @author Tyler Morgan
    # @see Jamf::DirectoryBinding
    # @see Jamf::DirectoryBindingType
    #
    # @param [Hash] initialize data
    def initialize(init_data)

        # Return without processing anything since there is
        # nothing to process.
        return if init_data.nil?

        # Process provided information
        @cache_last_user = init_data[:cache_last_user]
        @require_confirmation = init_data[:require_confirmation]
        @local_home = init_data[:local_home]
        @use_unc_path = init_data[:use_unc_path]
        @default_shell = init_data[:default_shell]
        @uid = init_data[:uid]
        @user_gid = init_data[:user_gid]
        @gid = init_data[:gid]
        @multiple_domains = init_data[:multiple_domains]
        @preferred_domain = init_data[:preferred_domain]
        @forest = init_data[:forest]

        if init_data[:mount_style].nil? || init_data[:mount_style].is_a?(String)
            raise Jamf::InvalidDataError, "Mount style must be one of #{NETWORK_PROTOCOL.values.join(', ')}." unless NETWORK_PROTOCOL.values.map { |x| x.downcase }.include?(init_data[:mount_style].downcase) || init_data[:mount_style].nil? 
            @mount_style = init_data[:mount_style]
        else
            raise Jamf::InvalidDataError, "Mount style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}," unless NETWORK_PROTOCOL.keys.include? init_data[:mount_style]

            @mount_style = NETWORK_PROTOCOL[init_data[:mount_style]]
        end

        if init_data[:admin_groups].nil?
            # This is needed since we have the ability to add and
            # remove admin groups from this array.
            @admin_groups = []
        elsif init_data[:admin_groups].is_a? String
            @admin_groups = init_data[:admin_groups].split(',')
        else
            @admin_groups = init_data[:admin_groups]
        end
    end

        

    # Public Instance Methods
    #####################################

    # Create mobile account upon login
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def cache_last_user=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "cache_last_user must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @cache_last_user = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Require confirmation before creating a mobile account on the system.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def require_confirmation=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @require_confirmation = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Force local home directory to be placed on the startup disk
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def local_home=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "local_home must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @local_home = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Attempt to derive the network home location using the UNC path stored inside Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the new value doesn't match a Bool value
    #
    # @return [void]
    def use_unc_path=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "use_unc_path must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @use_unc_path = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The protocol to be use when mounting network home location
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Symbol] One of the keys available in NETWORK_PROTOCOL
    # @see Jamf::DIRECTORYBINDINGTYPE::NETWORK_PROTOCOL
    #
    # @raise [Jamf::InvalidDataError] If the new value provided is not a key inside the NETWORK_PROTOCOL hash.
    #
    # @return [void]
    def mount_style=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "mount_style must be one of :#{NETWORK_PROTOCOL.keys.join(',:')}." unless NETWORK_PROTOCOL.keys.include? newvalue

        # Update Value
        @mount_style = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The directory path to the shell user's default shell will be set to upon login.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] Directory path for the specific shell that is wanting to be set.
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def default_shell=(newvalue)

        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @default_shell = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a UID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The UID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def uid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @uid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Specify a specific forest within Active Directory
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The forest you want to specify
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def forest=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
                newvalue
            end
        
        # Update Value
        @forest = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    # Map specific a User's GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The User's GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def user_gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end

        # Update Value
        @user_gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Map specific a GID to Attribute
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The GID you want to be mapped
    #
    # @raise [Jamf::InvalidDataError] If the new value is not a String
    #
    # @return [void]
    def gid=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
                newvalue
            end
        
        # Update Value
        @gid = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Will this computer be possibly connecting to multiple domains
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Bool]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a Bool.
    #
    # @return [void]
    def multiple_domains=(newvalue)

        # Data Check
        raise Jamf::InvalidDataError, "multiple_domains must be true or false." unless newvalue.is_a?(TrueClass) || newvalue.is_a?(FalseClass)

        # Update Value
        @multiple_domains = newvalue

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # What domain server should be highest priority
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not a String.
    #
    # @return [void]
    def preferred_domain=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
                newvalue
            end

        # Update Value
        @preferred_domain = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end

    
    # The AD group which can be considered administrators of a device.
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [Array <String>]
    #
    # @raise [Jamf::InvalidDataError] If the provided value is not an Array.
    #
    # @return [void]
    def admin_groups=(newvalue)
        new =
            if newvalue.to_s.empty?
                Jamf::BLANK
            else
                # Data Check
                raise Jamf::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
                
                if newvalue.is_a? Array
                    newvalue.join ","
                else
                    newvalue
                end
            end
            
        # Update Value
        @admin_groups = new

        # Set the object to needing to be updated.
        self.container&.should_update
    end


    # Add a specific admin group to the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to add to the admin group list
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def add_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Group \"#{value}\" already is in the admin groups." unless !@admin_groups.include? value

        @admin_groups << value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Remove a specific admin group from the admin_groups
    # 
    # @author Tyler Morgan
    #
    # @param newvalue [String] The admin group name you want to remove from the admin groups.
    #
    # @raise [Jamf::InvalidDataError] If the value provided is not a String
    # @raise [Jamf::InvalidDataError] If the group provided is not in the admin_group array
    #
    # @return [Array <String>] An array of all the admin groups currently set.
    def remove_admin_group(value)

        raise Jamf::InvalidDataError, "Admin group being removed must be a string." unless value.is_a? String
        raise Jamf::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_groups.include? value

        @admin_groups.delete value
        # Set the object to needing to be updated.
        self.container&.should_update

        return @admin_groups
    end


    # Return a REXML Element containing the current state of the DirectoryBindingType
    # object for adding into the XML of the container.
    # 
    # @author Tyler Morgan
    #
    # @return [REXML::Element]
    def type_setting_xml
        type_setting = REXML::Element.new "active_directory"
        type_setting.add_element("cache_last_user").text = @cache_last_user
        type_setting.add_element("require_confirmation").text = @require_confirmation
        type_setting.add_element("local_home").text = @local_home
        type_setting.add_element("use_unc_path").text = @use_unc_path
        type_setting.add_element("mount_style").text = @mount_style.downcase
        type_setting.add_element("default_shell").text = @default_shell
        type_setting.add_element("uid").text = @uid
        type_setting.add_element("user_gid").text = @user_gid
        type_setting.add_element("gid").text = @gid
        type_setting.add_element("multiple_domains").text = @multiple_domains
        type_setting.add_element("preferred_domain").text = @preferred_domain
        type_setting.add_element("admin_groups").text = @admin_groups.join(',').to_s unless @admin_groups.nil?
        type_setting.add_element("forest").text = @forest.to_s

        return type_setting
    end
end

Instance Method Details

#add_admin_group(value) ⇒ Array <String>

Add a specific admin group to the admin_groups

Parameters:

  • newvalue (String)

    The admin group name you want to add to the admin group list

Returns:

  • (Array <String>)

    An array of all the admin groups currently set.

Raises:

Author:

  • Tyler Morgan



477
478
479
480
481
482
483
484
485
486
487
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 477

def add_admin_group(value)

    raise Jamf::InvalidDataError, "Admin group must be a string." unless value.is_a? String
    raise Jamf::InvalidDataError, "Group \"#{value}\" already is in the admin groups." unless !@admin_groups.include? value

    @admin_groups << value
    # Set the object to needing to be updated.
    self.container&.should_update

    return @admin_groups
end

#remove_admin_group(value) ⇒ Array <String>

Remove a specific admin group from the admin_groups

Parameters:

  • newvalue (String)

    The admin group name you want to remove from the admin groups.

Returns:

  • (Array <String>)

    An array of all the admin groups currently set.

Raises:

Author:

  • Tyler Morgan



500
501
502
503
504
505
506
507
508
509
510
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 500

def remove_admin_group(value)

    raise Jamf::InvalidDataError, "Admin group being removed must be a string." unless value.is_a? String
    raise Jamf::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_groups.include? value

    @admin_groups.delete value
    # Set the object to needing to be updated.
    self.container&.should_update

    return @admin_groups
end

#type_setting_xmlREXML::Element

Return a REXML Element containing the current state of the DirectoryBindingType object for adding into the XML of the container.

Returns:

  • (REXML::Element)

Author:

  • Tyler Morgan



519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
# File 'lib/jamf/api/classic/api_objects/directory_binding_type/active_directory.rb', line 519

def type_setting_xml
    type_setting = REXML::Element.new "active_directory"
    type_setting.add_element("cache_last_user").text = @cache_last_user
    type_setting.add_element("require_confirmation").text = @require_confirmation
    type_setting.add_element("local_home").text = @local_home
    type_setting.add_element("use_unc_path").text = @use_unc_path
    type_setting.add_element("mount_style").text = @mount_style.downcase
    type_setting.add_element("default_shell").text = @default_shell
    type_setting.add_element("uid").text = @uid
    type_setting.add_element("user_gid").text = @user_gid
    type_setting.add_element("gid").text = @gid
    type_setting.add_element("multiple_domains").text = @multiple_domains
    type_setting.add_element("preferred_domain").text = @preferred_domain
    type_setting.add_element("admin_groups").text = @admin_groups.join(',').to_s unless @admin_groups.nil?
    type_setting.add_element("forest").text = @forest.to_s

    return type_setting
end