ruby-jss 1.4.1 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ruby-jss might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGES.md +38 -0
- data/lib/jamf.rb +10 -3
- data/lib/jamf/api/abstract_classes/collection_resource.rb +329 -150
- data/lib/jamf/api/abstract_classes/generic_reference.rb +9 -1
- data/lib/jamf/api/abstract_classes/json_object.rb +106 -82
- data/lib/jamf/api/abstract_classes/prestage.rb +54 -29
- data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +21 -0
- data/lib/jamf/api/abstract_classes/resource.rb +4 -4
- data/lib/jamf/api/abstract_classes/singleton_resource.rb +1 -1
- data/lib/jamf/api/connection.rb +13 -9
- data/lib/jamf/api/connection/api_error.rb +8 -8
- data/lib/jamf/api/connection/token.rb +16 -15
- data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +14 -1
- data/lib/jamf/api/json_objects/device_enrollment_device.rb +14 -7
- data/lib/jamf/api/json_objects/device_enrollment_device_sync_state.rb +81 -0
- data/lib/jamf/api/json_objects/locale.rb +59 -0
- data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +50 -1
- data/lib/jamf/api/json_objects/prestage_location.rb +3 -3
- data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +7 -7
- data/lib/jamf/api/json_objects/prestage_scope.rb +1 -1
- data/lib/jamf/api/{resources/collection_resources → json_objects}/time_zone.rb +9 -23
- data/lib/jamf/api/mixins/bulk_deletable.rb +27 -6
- data/lib/jamf/api/mixins/change_log.rb +201 -51
- data/lib/jamf/api/mixins/filterable.rb +51 -0
- data/lib/jamf/api/mixins/pageable.rb +208 -0
- data/lib/jamf/api/mixins/sortable.rb +59 -0
- data/lib/jamf/api/resources/collection_resources/building.rb +19 -8
- data/lib/jamf/api/resources/collection_resources/category.rb +5 -3
- data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +11 -4
- data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +10 -10
- data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +11 -3
- data/lib/jamf/api/resources/collection_resources/mobile_device_prestage.rb +24 -22
- data/lib/jamf/api/resources/collection_resources/script.rb +61 -25
- data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +15 -5
- data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +14 -14
- data/lib/jamf/api/resources/singleton_resources/locales.rb +155 -0
- data/lib/jamf/api/resources/singleton_resources/time_zones.rb +213 -0
- data/lib/jamf/validate.rb +63 -24
- data/lib/jamf/version.rb +1 -1
- data/lib/jss.rb +2 -1
- data/lib/jss/api_connection.rb +110 -370
- data/lib/jss/api_object.rb +3 -19
- data/lib/jss/api_object/categorizable.rb +1 -1
- data/lib/jss/api_object/configuration_profile.rb +34 -3
- data/lib/jss/api_object/directory_binding_type.rb +66 -60
- data/lib/jss/api_object/directory_binding_type/active_directory.rb +71 -34
- data/lib/jss/api_object/directory_binding_type/admitmac.rb +536 -467
- data/lib/jss/api_object/directory_binding_type/centrify.rb +21 -7
- data/lib/jss/api_object/directory_binding_type/open_directory.rb +4 -4
- data/lib/jss/api_object/distribution_point.rb +2 -2
- data/lib/jss/api_object/dock_item.rb +102 -96
- data/lib/jss/api_object/extendable.rb +1 -1
- data/lib/jss/api_object/group.rb +33 -2
- data/lib/jss/api_object/network_segment.rb +43 -12
- data/lib/jss/api_object/patch_source.rb +10 -9
- data/lib/jss/api_object/printer.rb +10 -4
- data/lib/jss/api_object/scopable.rb +10 -15
- data/lib/jss/exceptions.rb +3 -0
- data/lib/jss/server.rb +15 -0
- data/lib/jss/version.rb +1 -1
- metadata +37 -22
data/lib/jss/api_object.rb
CHANGED
@@ -849,11 +849,7 @@ module JSS
|
|
849
849
|
raise ArgumentError, 'Missing searchterm or fetch key'
|
850
850
|
end
|
851
851
|
|
852
|
-
|
853
|
-
return new fetch_rsrc: fetch_rsrc, api: api
|
854
|
-
rescue RestClient::NotFound
|
855
|
-
raise JSS::NoSuchItemError, "No #{self::RSRC_OBJECT_KEY} found #{err_detail}" unless fetch_rsrc
|
856
|
-
end
|
852
|
+
new fetch_rsrc: fetch_rsrc, api: api
|
857
853
|
end # fetch
|
858
854
|
|
859
855
|
# Fetch the mostly- or fully-raw JSON or XML data for an object of this
|
@@ -895,8 +891,6 @@ module JSS
|
|
895
891
|
return data if format == :json || as_string
|
896
892
|
|
897
893
|
REXML::Document.new(data)
|
898
|
-
rescue RestClient::NotFound
|
899
|
-
raise JSS::NoSuchItemError, "No #{self} with id #{id}"
|
900
894
|
end
|
901
895
|
|
902
896
|
# PUT some raw XML to the API for a given id in this subclass.
|
@@ -925,8 +919,6 @@ module JSS
|
|
925
919
|
validate_not_metaclass(self)
|
926
920
|
rsrc = "#{self::RSRC_BASE}/id/#{id}"
|
927
921
|
REXML::Document.new(api.put_rsrc rsrc, xml.to_s)
|
928
|
-
rescue RestClient::NotFound
|
929
|
-
raise JSS::NoSuchItemError, "No #{self} with id #{id}"
|
930
922
|
end
|
931
923
|
|
932
924
|
# POST some raw XML to the API for a given id in this subclass.
|
@@ -1223,14 +1215,8 @@ module JSS
|
|
1223
1215
|
#
|
1224
1216
|
def delete
|
1225
1217
|
return unless @in_jss
|
1226
|
-
|
1227
|
-
|
1228
|
-
rescue RestClient::NotFound, RestClient::ResourceNotFound
|
1229
|
-
# over slow connections (?) or more likely
|
1230
|
-
# split-tunnel VPN connections, sometimes the thing gets deleted
|
1231
|
-
# the call gets a 404 anyway
|
1232
|
-
nil
|
1233
|
-
end
|
1218
|
+
|
1219
|
+
@api.delete_rsrc @rest_rsrc
|
1234
1220
|
|
1235
1221
|
@rest_rsrc = "#{self.class::RSRC_BASE}/name/#{CGI.escape @name.to_s}"
|
1236
1222
|
@id = nil
|
@@ -1433,8 +1419,6 @@ module JSS
|
|
1433
1419
|
end
|
1434
1420
|
|
1435
1421
|
raw_json[args[:rsrc_object_key]]
|
1436
|
-
rescue RestClient::ResourceNotFound
|
1437
|
-
raise NoSuchItemError, "No #{self.class::RSRC_OBJECT_KEY} found matching resource #{rsrc}"
|
1438
1422
|
end
|
1439
1423
|
|
1440
1424
|
# Start examining the @init_data recieved from the API
|
@@ -198,7 +198,7 @@ module JSS
|
|
198
198
|
|
199
199
|
if cat.is_a? String
|
200
200
|
@category_name = cat
|
201
|
-
@category_id = JSS::Category.category_id_from_name @category_name
|
201
|
+
@category_id = JSS::Category.category_id_from_name @category_name, api: @api
|
202
202
|
else
|
203
203
|
@category_name = cat[:name]
|
204
204
|
@category_id = cat[:id]
|
@@ -23,7 +23,6 @@
|
|
23
23
|
#
|
24
24
|
#
|
25
25
|
|
26
|
-
#
|
27
26
|
module JSS
|
28
27
|
|
29
28
|
# Classes
|
@@ -68,7 +67,6 @@ module JSS
|
|
68
67
|
# How is the category stored in the API data?
|
69
68
|
CATEGORY_DATA_TYPE = Hash
|
70
69
|
|
71
|
-
|
72
70
|
# Attributes
|
73
71
|
###################################
|
74
72
|
|
@@ -125,12 +123,42 @@ module JSS
|
|
125
123
|
parsed_payloads['PayloadContent']
|
126
124
|
end
|
127
125
|
|
126
|
+
# @param new_content [Array<Hash>] replace the payload content entirely.
|
127
|
+
#
|
128
|
+
# The 'payload' of a config profile is an XML Plist. The top-level key
|
129
|
+
# of that plist 'PayloadContent' contains an Array of Dicts, each one being
|
130
|
+
# a part of the payload for the profile.
|
131
|
+
#
|
132
|
+
# When replacing the PayloadContent Array, using this method, provide a
|
133
|
+
# *ruby* Array full of *ruby* hashes, and they will be converted to a
|
134
|
+
# Plist and embedded into the API XML appropriately.
|
135
|
+
#
|
136
|
+
# WARNING: This is experimental! Editing the Plist Payload of a Config
|
137
|
+
# profile may break the profile. Make sure you test on a fake profile
|
138
|
+
# before using this method in production.
|
139
|
+
#
|
140
|
+
# @return [void]
|
141
|
+
#
|
142
|
+
def payload_content=(new_content)
|
143
|
+
payload_plist_data = parsed_payloads
|
144
|
+
payload_plist_data['PayloadContent'] = new_content
|
145
|
+
@payloads = payload_plist_data.to_plist
|
146
|
+
@need_to_update = true
|
147
|
+
@update_payloads = true
|
148
|
+
end
|
149
|
+
|
128
150
|
# @return [Array<String>] the PayloadType of each payload (e.g. com.apple.caldav.account)
|
129
151
|
#
|
130
152
|
def payload_types
|
131
153
|
payload_content.map { |p| p['PayloadType'] }
|
132
154
|
end
|
133
155
|
|
156
|
+
# clear flag after updating
|
157
|
+
def update
|
158
|
+
super
|
159
|
+
@update_payloads = nil
|
160
|
+
end
|
161
|
+
|
134
162
|
# Private Instance Methods
|
135
163
|
###################################
|
136
164
|
private
|
@@ -142,7 +170,10 @@ module JSS
|
|
142
170
|
gen = obj.add_element('general')
|
143
171
|
gen.add_element('description').text = @description
|
144
172
|
gen.add_element('redeploy_on_update').text = @redeploy_on_update
|
145
|
-
|
173
|
+
if @update_payloads
|
174
|
+
payloads_plist_xml = JSS.escape_xml(@payloads.gsub(/^\t*/, '').gsub(">\n", '>'))
|
175
|
+
gen.add_element('payloads').text = payloads_plist_xml
|
176
|
+
end
|
146
177
|
obj << @scope.scope_xml
|
147
178
|
add_self_service_xml doc
|
148
179
|
add_category_to_xml doc
|
@@ -25,66 +25,72 @@
|
|
25
25
|
|
26
26
|
module JSS
|
27
27
|
|
28
|
-
# Module for containing the different types of DirectoryBindings stored within the JSS
|
29
|
-
module DirectoryBindingType
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
28
|
+
# Module for containing the different types of DirectoryBindings stored within the JSS
|
29
|
+
module DirectoryBindingType
|
30
|
+
|
31
|
+
# Module Variables
|
32
|
+
#####################################
|
33
|
+
|
34
|
+
# Module Methods
|
35
|
+
#####################################
|
36
|
+
def should_update
|
37
|
+
@need_to_update = true
|
38
|
+
end
|
39
|
+
|
40
|
+
def set_type_settings(settings)
|
41
|
+
@type_settings = settings
|
42
|
+
@type_settings.container = self
|
43
|
+
end
|
44
|
+
|
45
|
+
# Classes
|
46
|
+
#####################################
|
47
|
+
|
48
|
+
# A generic binding type class that sets common variables, methods, and constructors
|
49
|
+
# for all the different directory binding types.
|
50
|
+
#
|
51
|
+
# @author Tyler Morgan
|
52
|
+
class DirectoryBindingType
|
53
|
+
|
54
|
+
|
55
|
+
# Mix-Ins
|
56
|
+
#####################################
|
57
|
+
|
58
|
+
# Class Methods
|
59
|
+
#####################################
|
60
|
+
|
61
|
+
# Class Constants
|
62
|
+
#####################################
|
63
|
+
|
64
|
+
# The different network protocols supported.
|
65
|
+
NETWORK_PROTOCOL = {
|
66
|
+
afp: 'AFP',
|
67
|
+
smb: 'SMB'
|
68
|
+
}.freeze
|
69
|
+
|
70
|
+
# The different home folder types.
|
71
|
+
HOME_FOLDER_TYPE = {
|
72
|
+
network: 'Network',
|
73
|
+
local: 'Local',
|
74
|
+
either: 'Either',
|
75
|
+
mobile: 'Mobile'
|
76
|
+
}.freeze
|
77
|
+
|
78
|
+
# Attributes
|
79
|
+
#####################################
|
80
|
+
|
81
|
+
# This is used to properly handle updating the containing object.
|
82
|
+
attr_accessor :container
|
83
|
+
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
83
88
|
end
|
89
|
+
|
84
90
|
end
|
85
91
|
|
86
|
-
require
|
87
|
-
require
|
88
|
-
require
|
89
|
-
require
|
90
|
-
require
|
92
|
+
require 'jss/api_object/directory_binding_type/active_directory'
|
93
|
+
require 'jss/api_object/directory_binding_type/open_directory'
|
94
|
+
require 'jss/api_object/directory_binding_type/admitmac'
|
95
|
+
require 'jss/api_object/directory_binding_type/centrify'
|
96
|
+
require 'jss/api_object/directory_binding_type/powerbroker_identity_services'
|
@@ -259,11 +259,17 @@ module JSS
|
|
259
259
|
# @return [void]
|
260
260
|
def default_shell=(newvalue)
|
261
261
|
|
262
|
-
|
263
|
-
|
262
|
+
new =
|
263
|
+
if newvalue.to_s.empty?
|
264
|
+
JSS::BLANK
|
265
|
+
else
|
266
|
+
# Data Check
|
267
|
+
raise JSS::InvalidDataError, "default_shell must be a string." unless newvalue.is_a? String
|
268
|
+
newvalue
|
269
|
+
end
|
264
270
|
|
265
271
|
# Update Value
|
266
|
-
@default_shell =
|
272
|
+
@default_shell = new
|
267
273
|
|
268
274
|
# Set the object to needing to be updated.
|
269
275
|
self.container&.should_update
|
@@ -280,12 +286,17 @@ module JSS
|
|
280
286
|
#
|
281
287
|
# @return [void]
|
282
288
|
def uid=(newvalue)
|
283
|
-
|
284
|
-
|
285
|
-
|
289
|
+
new =
|
290
|
+
if newvalue.to_s.empty?
|
291
|
+
JSS::BLANK
|
292
|
+
else
|
293
|
+
# Data Check
|
294
|
+
raise JSS::InvalidDataError, "uid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
|
295
|
+
newvalue
|
296
|
+
end
|
286
297
|
|
287
298
|
# Update Value
|
288
|
-
@uid =
|
299
|
+
@uid = new
|
289
300
|
|
290
301
|
# Set the object to needing to be updated.
|
291
302
|
self.container&.should_update
|
@@ -302,12 +313,17 @@ module JSS
|
|
302
313
|
#
|
303
314
|
# @return [void]
|
304
315
|
def forest=(newvalue)
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
316
|
+
new =
|
317
|
+
if newvalue.to_s.empty?
|
318
|
+
JSS::BLANK
|
319
|
+
else
|
320
|
+
# Data Check
|
321
|
+
raise JSS::InvalidDataError, "forest must be a string." unless newvalue.is_a? String
|
322
|
+
newvalue
|
323
|
+
end
|
324
|
+
|
309
325
|
# Update Value
|
310
|
-
@forest =
|
326
|
+
@forest = new
|
311
327
|
|
312
328
|
# Set the object to needing to be updated.
|
313
329
|
self.container&.should_update
|
@@ -323,12 +339,17 @@ module JSS
|
|
323
339
|
#
|
324
340
|
# @return [void]
|
325
341
|
def user_gid=(newvalue)
|
326
|
-
|
327
|
-
|
328
|
-
|
342
|
+
new =
|
343
|
+
if newvalue.to_s.empty?
|
344
|
+
JSS::BLANK
|
345
|
+
else
|
346
|
+
# Data Check
|
347
|
+
raise JSS::InvalidDataError, "user_gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
|
348
|
+
newvalue
|
349
|
+
end
|
329
350
|
|
330
351
|
# Update Value
|
331
|
-
@user_gid =
|
352
|
+
@user_gid = new
|
332
353
|
|
333
354
|
# Set the object to needing to be updated.
|
334
355
|
self.container&.should_update
|
@@ -345,12 +366,17 @@ module JSS
|
|
345
366
|
#
|
346
367
|
# @return [void]
|
347
368
|
def gid=(newvalue)
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
369
|
+
new =
|
370
|
+
if newvalue.to_s.empty?
|
371
|
+
JSS::BLANK
|
372
|
+
else
|
373
|
+
# Data Check
|
374
|
+
raise JSS::InvalidDataError, "gid must be either an integer or a string." unless (newvalue.is_a? Integer || newvalue.is_a?(String))
|
375
|
+
newvalue
|
376
|
+
end
|
377
|
+
|
352
378
|
# Update Value
|
353
|
-
@gid =
|
379
|
+
@gid = new
|
354
380
|
|
355
381
|
# Set the object to needing to be updated.
|
356
382
|
self.container&.should_update
|
@@ -389,12 +415,17 @@ module JSS
|
|
389
415
|
#
|
390
416
|
# @return [void]
|
391
417
|
def preferred_domain=(newvalue)
|
392
|
-
|
393
|
-
|
394
|
-
|
418
|
+
new =
|
419
|
+
if newvalue.to_s.empty?
|
420
|
+
JSS::BLANK
|
421
|
+
else
|
422
|
+
# Data Check
|
423
|
+
raise JSS::InvalidDataError, "preferred_domain must be a string." unless newvalue.is_a? String
|
424
|
+
newvalue
|
425
|
+
end
|
395
426
|
|
396
427
|
# Update Value
|
397
|
-
@preferred_domain =
|
428
|
+
@preferred_domain = new
|
398
429
|
|
399
430
|
# Set the object to needing to be updated.
|
400
431
|
self.container&.should_update
|
@@ -411,16 +442,22 @@ module JSS
|
|
411
442
|
#
|
412
443
|
# @return [void]
|
413
444
|
def admin_groups=(newvalue)
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
445
|
+
new =
|
446
|
+
if newvalue.to_s.empty?
|
447
|
+
JSS::BLANK
|
448
|
+
else
|
449
|
+
# Data Check
|
450
|
+
raise JSS::InvalidDataError, "admin_groups must be either a string or an array of strings." unless (newvalue.is_a? String || newvalue.is_a?(Array))
|
451
|
+
|
452
|
+
if newvalue.is_a? Array
|
453
|
+
newvalue.join ","
|
454
|
+
else
|
455
|
+
newvalue
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
418
459
|
# Update Value
|
419
|
-
|
420
|
-
@admin_groups = newvalue.join ","
|
421
|
-
else
|
422
|
-
@admin_groups = newvalue
|
423
|
-
end
|
460
|
+
@admin_groups = new
|
424
461
|
|
425
462
|
# Set the object to needing to be updated.
|
426
463
|
self.container&.should_update
|
@@ -24,502 +24,571 @@
|
|
24
24
|
###
|
25
25
|
|
26
26
|
module JSS
|
27
|
-
|
28
|
-
# Module for containing the different types of DirectoryBindings stored within the JSS
|
29
|
-
|
30
|
-
module DirectoryBindingType
|
31
|
-
|
32
|
-
# Module Variables
|
33
|
-
#####################################
|
34
|
-
|
35
|
-
# Module Methods
|
36
|
-
#####################################
|
37
|
-
|
38
|
-
# Classes
|
39
|
-
#####################################
|
40
|
-
|
41
|
-
# Class for the specific ADmitMac DirectoryBinding type stored within the JSS
|
42
|
-
#
|
43
|
-
# @author Tyler Morgan
|
44
|
-
#
|
45
|
-
# @note "Map Home Directory To Attribute" is currently only available in the Jamf Pro UI not through the API.
|
46
|
-
#
|
47
|
-
# Attributes
|
48
|
-
# @!attribute [rw] require_confirmation
|
49
|
-
# @!attribute [rw] local_home
|
50
|
-
# @!attribute [rw] mount_style
|
51
|
-
# @!attribute [rw] default_shell
|
52
|
-
# @!attribute [rw] mount_network_home
|
53
|
-
# @!attribute [rw] place_home_folders
|
54
|
-
# @!attribute [rw] uid
|
55
|
-
# @!attribute [rw] user_gid
|
56
|
-
# @!attribute [rw] gid
|
57
|
-
# @!attribute [rw] admin_group
|
58
|
-
# @!attribute [rw] cached_credentials
|
59
|
-
# @!attribute [rw] add_user_to_local
|
60
|
-
# @!attribute [rw] users_ou
|
61
|
-
# @!attribute [rw] groups_ou
|
62
|
-
# @!attribute [rw] printers_ou
|
63
|
-
# @!attribute [rw] shared_folders_ou
|
64
|
-
# TODO: Include default values upon creation
|
65
|
-
|
66
|
-
class ADmitMac < DirectoryBindingType
|
67
|
-
# Mix-Ins
|
68
|
-
#####################################
|
69
|
-
|
70
|
-
# Class Methods
|
71
|
-
#####################################
|
72
|
-
|
73
|
-
# Class Constants
|
74
|
-
#####################################
|
75
|
-
|
76
|
-
# Attributes
|
77
|
-
#####################################
|
78
|
-
|
79
|
-
attr_reader :require_confirmation
|
80
|
-
attr_reader :local_home
|
81
|
-
attr_reader :mount_style
|
82
|
-
attr_reader :default_shell
|
83
|
-
attr_reader :mount_network_home
|
84
|
-
attr_reader :place_home_folders
|
85
|
-
attr_reader :uid
|
86
|
-
attr_reader :user_gid
|
87
|
-
attr_reader :gid
|
88
|
-
attr_reader :admin_group
|
89
|
-
attr_reader :cached_credentials
|
90
|
-
attr_reader :add_user_to_local
|
91
|
-
attr_reader :users_ou
|
92
|
-
attr_reader :groups_ou
|
93
|
-
attr_reader :printers_ou
|
94
|
-
attr_reader :shared_folders_ou
|
95
|
-
|
96
|
-
# Constructor
|
97
|
-
#####################################
|
98
|
-
|
99
|
-
# An initializer for the ADmitMac object.
|
100
|
-
#
|
101
|
-
# @author Tyler Morgan
|
102
|
-
# @see JSS::DirectoryBinding
|
103
|
-
# @see JSS::DirectoryBindingType
|
104
|
-
#
|
105
|
-
# @note Due to a JSS API funk, mount_style is not able to be configured through the API. It is linked to place_home_folders
|
106
|
-
#
|
107
|
-
# @param [Hash] initialize data
|
108
|
-
def initialize(init_data)
|
109
|
-
|
110
|
-
# Return without processing anything since there is
|
111
|
-
# nothing to process.
|
112
|
-
return if init_data.nil?
|
113
|
-
|
114
|
-
# Process the provided information
|
115
|
-
@require_confirmation = init_data[:require_confirmation]
|
116
|
-
@default_shell = init_data[:default_shell]
|
117
|
-
@mount_network_home = init_data[:mount_network_home]
|
118
|
-
@place_home_folders = init_data[:place_home_folders]
|
119
|
-
@uid = init_data[:uid]
|
120
|
-
@user_gid = init_data[:user_gid]
|
121
|
-
@gid = init_data[:gid]
|
122
|
-
@cached_credentials = init_data[:cached_credentials]
|
123
|
-
@add_user_to_local = init_data[:add_user_to_local]
|
124
|
-
@users_ou = init_data[:users_ou]
|
125
|
-
@groups_ou = init_data[:groups_ou]
|
126
|
-
@printers_ou = init_data[:printers_ou]
|
127
|
-
@shared_folders_ou = init_data[:shared_folders_ou]
|
128
|
-
@mount_style = init_data[:mount_style]
|
129
|
-
|
130
|
-
if init_data[:local_home].nil? || init_data[:local_home].is_a?(String)
|
131
|
-
raise JSS::InvalidDataError, "Local Home must be one of #{HOME_FOLDER_TYPE.values.join(', ')}." unless HOME_FOLDER_TYPE.values.include? init_data[:local_home] || init_data[:local_home].nil?
|
132
|
-
|
133
|
-
@local_home = init_data[:local_home]
|
134
|
-
else
|
135
|
-
raise JSS::InvalidDataError, "Local Home must be one of :#{HOME_FOLDER_TYPE.keys.join(',:')}." unless HOME_FOLDER_TYPE.keys.include? init_data[:local_home]
|
136
|
-
end
|
137
|
-
|
138
|
-
if init_data[:admin_group].nil?
|
139
|
-
# This is needed since we have the ability to add and
|
140
|
-
# remove admin groups from this array.
|
141
|
-
@admin_group = []
|
142
|
-
elsif init_data[:admin_group].is_a? String
|
143
|
-
@admin_group = init_data[:admin_group].split(',')
|
144
|
-
else
|
145
|
-
@admin_group = init_data[:admin_group]
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
# Public Instance Methods
|
152
|
-
#####################################
|
153
|
-
|
154
|
-
# Require confirmation before creating a mobile account on the system.
|
155
|
-
#
|
156
|
-
# @author Tyler Morgan
|
157
|
-
#
|
158
|
-
# @param newvalue [Bool]
|
159
|
-
#
|
160
|
-
# @raise [JSS::InvalidDataError] If the new value doesn't match a Bool value
|
161
|
-
#
|
162
|
-
# @return [void]
|
163
|
-
def require_confirmation=(newvalue)
|
164
|
-
|
165
|
-
raise JSS::InvalidDataError, "require_confirmation must be true or false." unless newvalue.is_a? Bool
|
166
|
-
|
167
|
-
@require_confirmation = newvalue
|
168
|
-
|
169
|
-
self.container&.should_update
|
170
|
-
end
|
171
|
-
|
172
|
-
|
173
|
-
# The type of home directory type created upon logging into a system
|
174
|
-
#
|
175
|
-
# @author Tyler Morgan
|
176
|
-
#
|
177
|
-
# @param newvalue [Symbol] The key specific to the folder type you want in HOME_FOLDER_TYPE
|
178
|
-
# @see JSS::DirectoryBindingType::HOME_FOLDER_TYPE
|
179
|
-
#
|
180
|
-
# @raise [JSS::InvalidDataError] If the new value is not one of the possible keys in HOME_FOLDER_TYPE
|
181
|
-
#
|
182
|
-
# @return [void]
|
183
|
-
def local_home=(newvalue)
|
184
|
-
|
185
|
-
raise JSS::InvalidDataError, "local_home must be one of :#{HOME_FOLDER_TYPE.keys.join(',:')}." unless HOME_FOLDER_TYPE.keys.include? newvalue
|
186
|
-
|
187
|
-
@local_home = HOME_FOLDER_TYPE[newvalue]
|
188
|
-
|
189
|
-
self.container&.should_update
|
190
|
-
end
|
191
|
-
|
192
|
-
# The default shell assigned first upon logging into a system
|
193
|
-
#
|
194
|
-
# @author Tyler Morgan
|
195
|
-
#
|
196
|
-
# @param newvalue [String] The string path of the shell file being set as the default
|
197
|
-
#
|
198
|
-
# @raise [JSS::InvalidDataError] If the new value is not a String
|
199
|
-
#
|
200
|
-
# @return [void]
|
201
|
-
def default_shell=(newvalue)
|
202
|
-
|
203
|
-
raise JSS::InvalidDataError, "default_shell must be empty or a string." unless newvalue.is_a?(String)
|
204
|
-
|
205
|
-
@default_shell = newvalue
|
206
|
-
|
207
|
-
self.container&.should_update
|
208
|
-
end
|
209
27
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
28
|
+
# Module for containing the different types of DirectoryBindings stored within the JSS
|
29
|
+
|
30
|
+
module DirectoryBindingType
|
31
|
+
|
32
|
+
# Module Variables
|
33
|
+
#####################################
|
34
|
+
|
35
|
+
# Module Methods
|
36
|
+
#####################################
|
37
|
+
|
38
|
+
# Classes
|
39
|
+
#####################################
|
40
|
+
|
41
|
+
# Class for the specific ADmitMac DirectoryBinding type stored within the JSS
|
42
|
+
#
|
43
|
+
# @author Tyler Morgan
|
44
|
+
#
|
45
|
+
# @note "Map Home Directory To Attribute" is currently only available in the Jamf Pro UI not through the API.
|
46
|
+
#
|
47
|
+
# Attributes
|
48
|
+
# @!attribute [rw] require_confirmation
|
49
|
+
# @!attribute [rw] local_home
|
50
|
+
# @!attribute [rw] mount_style
|
51
|
+
# @!attribute [rw] default_shell
|
52
|
+
# @!attribute [rw] mount_network_home
|
53
|
+
# @!attribute [rw] place_home_folders
|
54
|
+
# @!attribute [rw] uid
|
55
|
+
# @!attribute [rw] user_gid
|
56
|
+
# @!attribute [rw] gid
|
57
|
+
# @!attribute [rw] admin_group
|
58
|
+
# @!attribute [rw] cached_credentials
|
59
|
+
# @!attribute [rw] add_user_to_local
|
60
|
+
# @!attribute [rw] users_ou
|
61
|
+
# @!attribute [rw] groups_ou
|
62
|
+
# @!attribute [rw] printers_ou
|
63
|
+
# @!attribute [rw] shared_folders_ou
|
64
|
+
# TODO: Include default values upon creation
|
65
|
+
class ADmitMac < DirectoryBindingType
|
66
|
+
|
67
|
+
# Mix-Ins
|
68
|
+
#####################################
|
69
|
+
|
70
|
+
# Class Methods
|
71
|
+
#####################################
|
72
|
+
|
73
|
+
# Class Constants
|
74
|
+
#####################################
|
75
|
+
|
76
|
+
# Attributes
|
77
|
+
#####################################
|
78
|
+
|
79
|
+
attr_reader :require_confirmation
|
80
|
+
attr_reader :local_home
|
81
|
+
attr_reader :mount_style
|
82
|
+
attr_reader :default_shell
|
83
|
+
attr_reader :mount_network_home
|
84
|
+
attr_reader :place_home_folders
|
85
|
+
attr_reader :uid
|
86
|
+
attr_reader :user_gid
|
87
|
+
attr_reader :gid
|
88
|
+
attr_reader :admin_group
|
89
|
+
attr_reader :cached_credentials
|
90
|
+
attr_reader :add_user_to_local
|
91
|
+
attr_reader :users_ou
|
92
|
+
attr_reader :groups_ou
|
93
|
+
attr_reader :printers_ou
|
94
|
+
attr_reader :shared_folders_ou
|
95
|
+
|
96
|
+
# Constructor
|
97
|
+
#####################################
|
98
|
+
|
99
|
+
# An initializer for the ADmitMac object.
|
100
|
+
#
|
101
|
+
# @author Tyler Morgan
|
102
|
+
# @see JSS::DirectoryBinding
|
103
|
+
# @see JSS::DirectoryBindingType
|
104
|
+
#
|
105
|
+
# @note Due to a JSS API funk, mount_style is not able to be configured through the API. It is linked to place_home_folders
|
106
|
+
#
|
107
|
+
# @param [Hash] initialize data
|
108
|
+
def initialize(init_data)
|
109
|
+
# Return without processing anything since there is
|
110
|
+
# nothing to process.
|
111
|
+
return if init_data.nil?
|
112
|
+
|
113
|
+
# Process the provided information
|
114
|
+
@require_confirmation = init_data[:require_confirmation]
|
115
|
+
@default_shell = init_data[:default_shell]
|
116
|
+
@mount_network_home = init_data[:mount_network_home]
|
117
|
+
@place_home_folders = init_data[:place_home_folders]
|
118
|
+
@uid = init_data[:uid]
|
119
|
+
@user_gid = init_data[:user_gid]
|
120
|
+
@gid = init_data[:gid]
|
121
|
+
@cached_credentials = init_data[:cached_credentials]
|
122
|
+
@add_user_to_local = init_data[:add_user_to_local]
|
123
|
+
@users_ou = init_data[:users_ou]
|
124
|
+
@groups_ou = init_data[:groups_ou]
|
125
|
+
@printers_ou = init_data[:printers_ou]
|
126
|
+
@shared_folders_ou = init_data[:shared_folders_ou]
|
127
|
+
@mount_style = init_data[:mount_style]
|
128
|
+
|
129
|
+
if init_data[:local_home].nil? || init_data[:local_home].is_a?(String)
|
130
|
+
unless HOME_FOLDER_TYPE.values.include? init_data[:local_home] || init_data[:local_home].nil?
|
131
|
+
raise JSS::InvalidDataError, "Local Home must be one of #{HOME_FOLDER_TYPE.values.join(', ')}."
|
227
132
|
end
|
228
133
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
# @param newvalue [String] The string path of the folder which user's directory files and folders will be created
|
234
|
-
#
|
235
|
-
# @raise [JSS::InvalidDataError] If the new value is not a String
|
236
|
-
#
|
237
|
-
# @return [void]
|
238
|
-
def place_home_folders=(newvalue)
|
239
|
-
|
240
|
-
raise JSS::InvalidDataError, "place_home_folders must be a string." unless newvalue.is_a? String
|
241
|
-
|
242
|
-
@place_home_folders = newvalue
|
243
|
-
|
244
|
-
self.container&.should_update
|
134
|
+
@local_home = init_data[:local_home]
|
135
|
+
else
|
136
|
+
unless HOME_FOLDER_TYPE.keys.include? init_data[:local_home]
|
137
|
+
raise JSS::InvalidDataError, "Local Home must be one of :#{HOME_FOLDER_TYPE.keys.join(',:')}."
|
245
138
|
end
|
139
|
+
end
|
246
140
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
141
|
+
@admin_group = if init_data[:admin_group].nil?
|
142
|
+
# This is needed since we have the ability to add and
|
143
|
+
# remove admin groups from this array.
|
144
|
+
[]
|
145
|
+
elsif init_data[:admin_group].is_a? String
|
146
|
+
init_data[:admin_group].split(',')
|
147
|
+
else
|
148
|
+
init_data[:admin_group]
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Public Instance Methods
|
153
|
+
#####################################
|
154
|
+
|
155
|
+
# Require confirmation before creating a mobile account on the system.
|
156
|
+
#
|
157
|
+
# @author Tyler Morgan
|
158
|
+
#
|
159
|
+
# @param newvalue [Bool]
|
160
|
+
#
|
161
|
+
# @raise [JSS::InvalidDataError] If the new value doesn't match a Bool value
|
162
|
+
#
|
163
|
+
# @return [void]
|
164
|
+
def require_confirmation=(newvalue)
|
165
|
+
raise JSS::InvalidDataError, 'require_confirmation must be true or false.' unless newvalue.is_a?(TrueClass) || newvalue.is_a(FalseClass)
|
166
|
+
|
167
|
+
@require_confirmation = newvalue
|
168
|
+
|
169
|
+
container&.should_update
|
170
|
+
end
|
171
|
+
|
172
|
+
# The type of home directory type created upon logging into a system
|
173
|
+
#
|
174
|
+
# @author Tyler Morgan
|
175
|
+
#
|
176
|
+
# @param newvalue [Symbol] The key specific to the folder type you want in HOME_FOLDER_TYPE
|
177
|
+
# @see JSS::DirectoryBindingType::HOME_FOLDER_TYPE
|
178
|
+
#
|
179
|
+
# @raise [JSS::InvalidDataError] If the new value is not one of the possible keys in HOME_FOLDER_TYPE
|
180
|
+
#
|
181
|
+
# @return [void]
|
182
|
+
def local_home=(newvalue)
|
183
|
+
new =
|
184
|
+
if newvalue.to_s.empty?
|
185
|
+
JSS::BLANK
|
186
|
+
else
|
187
|
+
# Data Check
|
188
|
+
raise JSS::InvalidDataError, "local_home must be one of :#{HOME_FOLDER_TYPE.keys.join(',:')}." unless HOME_FOLDER_TYPE.keys.include? newvalue
|
189
|
+
|
190
|
+
HOME_FOLDER_TYPE[newvalue]
|
267
191
|
end
|
268
192
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
193
|
+
@local_home = new
|
194
|
+
|
195
|
+
container&.should_update
|
196
|
+
end
|
197
|
+
|
198
|
+
# The default shell assigned first upon logging into a system
|
199
|
+
#
|
200
|
+
# @author Tyler Morgan
|
201
|
+
#
|
202
|
+
# @param newvalue [String] The string path of the shell file being set as the default
|
203
|
+
#
|
204
|
+
# @raise [JSS::InvalidDataError] If the new value is not a String
|
205
|
+
#
|
206
|
+
# @return [void]
|
207
|
+
def default_shell=(newvalue)
|
208
|
+
new =
|
209
|
+
if newvalue.to_s.empty?
|
210
|
+
JSS::BLANK
|
211
|
+
else
|
212
|
+
# Data Check
|
213
|
+
raise JSS::InvalidDataError, 'default_shell must be empty or a string.' unless newvalue.is_a?(String)
|
214
|
+
|
215
|
+
newvalue
|
286
216
|
end
|
287
217
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
218
|
+
@default_shell = new
|
219
|
+
|
220
|
+
container&.should_update
|
221
|
+
end
|
222
|
+
|
223
|
+
# Mount network home folder on desktop
|
224
|
+
#
|
225
|
+
# @author Tyler Morgan
|
226
|
+
#
|
227
|
+
# @param newvalue [Bool]
|
228
|
+
#
|
229
|
+
# @raise [JSS::InvalidDataError] If the new value is not a Bool
|
230
|
+
#
|
231
|
+
# @return [void]
|
232
|
+
def mount_network_home=(newvalue)
|
233
|
+
raise JSS::InvalidDataError, 'mount_network_home must be true or false.' unless newvalue.is_a?(TrueClass) || newvalue.is_a(FalseClass)
|
234
|
+
|
235
|
+
@mount_network_home = newvalue
|
236
|
+
|
237
|
+
container&.should_update
|
238
|
+
end
|
239
|
+
|
240
|
+
# Path at which home folders are placed
|
241
|
+
#
|
242
|
+
# @author Tyler Morgan
|
243
|
+
#
|
244
|
+
# @param newvalue [String] The string path of the folder which user's directory files and folders will be created
|
245
|
+
#
|
246
|
+
# @raise [JSS::InvalidDataError] If the new value is not a String
|
247
|
+
#
|
248
|
+
# @return [void]
|
249
|
+
def place_home_folders=(newvalue)
|
250
|
+
new =
|
251
|
+
if newvalue.to_s.empty?
|
252
|
+
JSS::BLANK
|
253
|
+
else
|
254
|
+
# Data Check
|
255
|
+
raise JSS::InvalidDataError, 'place_home_folders must be a string.' unless newvalue.is_a? String
|
256
|
+
|
257
|
+
newvalue
|
305
258
|
end
|
306
259
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
260
|
+
@place_home_folders = new
|
261
|
+
|
262
|
+
container&.should_update
|
263
|
+
end
|
264
|
+
|
265
|
+
# Jamf has these linked for some reason...
|
266
|
+
alias mount_style place_home_folders
|
267
|
+
|
268
|
+
# Map specific UID to Attribute
|
269
|
+
#
|
270
|
+
# @author Tyler Morgan
|
271
|
+
#
|
272
|
+
# @param newvalue [String] The UID you want to be mapped
|
273
|
+
#
|
274
|
+
# @raise [JSS::InvalidDataError] If the new value is not a String
|
275
|
+
#
|
276
|
+
# @return [void]
|
277
|
+
def uid=(newvalue)
|
278
|
+
new =
|
279
|
+
if newvalue.to_s.empty?
|
280
|
+
JSS::BLANK
|
281
|
+
else
|
282
|
+
# Data Check
|
283
|
+
raise JSS::InvalidDataError, 'uid must be a string, integer, or nil.' unless newvalue.is_a?(String) || newvalue.is_a?(Integer) || newvalue.nil?
|
284
|
+
|
285
|
+
newvalue
|
325
286
|
end
|
326
287
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
288
|
+
@uid = new
|
289
|
+
|
290
|
+
container&.should_update
|
291
|
+
end
|
292
|
+
|
293
|
+
# Map specific a User's GID to Attribute
|
294
|
+
#
|
295
|
+
# @author Tyler Morgan
|
296
|
+
#
|
297
|
+
# @param newvalue [String] The User's GID you want to be mapped
|
298
|
+
#
|
299
|
+
# @raise [JSS::InvalidDataError] If the new value is not a String
|
300
|
+
#
|
301
|
+
# @return [void]
|
302
|
+
def user_gid=(newvalue)
|
303
|
+
new =
|
304
|
+
if newvalue.to_s.empty?
|
305
|
+
JSS::BLANK
|
306
|
+
else
|
307
|
+
# Data Check
|
308
|
+
raise JSS::InvalidDataError, 'user_gid must be a string, integer, or nil.' unless newvalue.is_a?(String) || newvalue.is_a?(Integer) || newvalue.nil?
|
309
|
+
|
310
|
+
newvalue
|
344
311
|
end
|
345
312
|
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
313
|
+
@user_gid = new
|
314
|
+
|
315
|
+
container&.should_update
|
316
|
+
end
|
317
|
+
|
318
|
+
# Map specific GID to Attribute
|
319
|
+
#
|
320
|
+
# @author Tyler Morgan
|
321
|
+
#
|
322
|
+
# @param newvalue [String] The GID you want to be mapped
|
323
|
+
#
|
324
|
+
# @raise [JSS::InvalidDataError] If the new value is not a String
|
325
|
+
#
|
326
|
+
# @return [void]
|
327
|
+
def gid=(newvalue)
|
328
|
+
new =
|
329
|
+
if newvalue.to_s.empty?
|
330
|
+
JSS::BLANK
|
331
|
+
else
|
332
|
+
# Data Check
|
333
|
+
raise JSS::InvalidDataError, 'gid must be a string, integer, or nil.' unless newvalue.is_a?(String) || newvalue.is_a?(Integer) || newvalue.nil?
|
334
|
+
|
335
|
+
newvalue
|
365
336
|
end
|
366
337
|
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
338
|
+
@gid = new
|
339
|
+
|
340
|
+
container&.should_update
|
341
|
+
end
|
342
|
+
|
343
|
+
# Set specific groups to become administrators to a system.
|
344
|
+
#
|
345
|
+
# @author Tyler Morgan
|
346
|
+
#
|
347
|
+
# @param newvalue [Array<String>] An array of all the admin group names you want to set.
|
348
|
+
# @see add_admin_group
|
349
|
+
# @see remove_admin_group
|
350
|
+
#
|
351
|
+
# @raise [JSS::InvalidDataError] If the new value is not an Array
|
352
|
+
#
|
353
|
+
# @return [void]
|
354
|
+
def admin_group=(newvalue)
|
355
|
+
new =
|
356
|
+
if newvalue.to_s.empty?
|
357
|
+
JSS::BLANK
|
358
|
+
else
|
359
|
+
# Data Check
|
360
|
+
unless newvalue.is_a? Array
|
361
|
+
raise JSS::InvalidDataError, 'An Array must be provided, please use add_admin_group and remove_admin_group for individual group additions and removals.'
|
362
|
+
end
|
363
|
+
|
364
|
+
newvalue
|
385
365
|
end
|
386
366
|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
367
|
+
@admin_group = new
|
368
|
+
|
369
|
+
container&.should_update
|
370
|
+
end
|
371
|
+
|
372
|
+
# The number of times a user can log into the device while not connected to a network
|
373
|
+
#
|
374
|
+
# @author Tyler Morgan
|
375
|
+
#
|
376
|
+
# @param newvalue [Integer] The number of times you want a user to login while not connected to a network
|
377
|
+
#
|
378
|
+
# @raise [JSS::InvalidDataError] If the new value is not an Integer
|
379
|
+
#
|
380
|
+
# @return [void]
|
381
|
+
def cached_credentials=(newvalue)
|
382
|
+
new =
|
383
|
+
if newvalue.to_s.empty?
|
384
|
+
JSS::BLANK
|
385
|
+
else
|
386
|
+
# Data Check
|
387
|
+
raise JSS::InvalidDataError, 'cached_credentials must be an integer.' unless newvalue.is_a? Integer
|
388
|
+
|
389
|
+
newvalue
|
405
390
|
end
|
406
391
|
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
392
|
+
@cached_credentials = new
|
393
|
+
|
394
|
+
container&.should_update
|
395
|
+
end
|
396
|
+
|
397
|
+
# If the user is a member of one of the groups in admin_group, add them
|
398
|
+
# to the local administrator group.
|
399
|
+
#
|
400
|
+
# @author Tyler Morgan
|
401
|
+
# @see admin_group
|
402
|
+
#
|
403
|
+
# @param newvalue [Bool]
|
404
|
+
#
|
405
|
+
# @raise [JSS::InvalidDataError] If the new value is not a Bool
|
406
|
+
#
|
407
|
+
# @return [void]
|
408
|
+
def add_user_to_local=(newvalue)
|
409
|
+
raise JSS::InvalidDataError, 'add_user_to_local must be true or false.' unless newvalue.is_a?(TrueClass) || newvalue.is_a(FalseClass)
|
410
|
+
|
411
|
+
@add_user_to_local = newvalue
|
412
|
+
|
413
|
+
container&.should_update
|
414
|
+
end
|
415
|
+
|
416
|
+
# An OU path for specific Users
|
417
|
+
#
|
418
|
+
# @author Tyler Morgan
|
419
|
+
#
|
420
|
+
# @param newvalue [String] The OU path for the specific user
|
421
|
+
# @note Not sure what this is used for
|
422
|
+
#
|
423
|
+
# @raise [JSS::InvalidDataError] If the new value is not a String
|
424
|
+
#
|
425
|
+
# @return [void]
|
426
|
+
def users_ou=(newvalue)
|
427
|
+
new =
|
428
|
+
if newvalue.to_s.empty?
|
429
|
+
JSS::BLANK
|
430
|
+
else
|
431
|
+
# Data Check
|
432
|
+
raise JSS::InvalidDataError, 'users_ou must be either a string or nil.' unless newvalue.is_a? String || newvalue.nil?
|
433
|
+
|
434
|
+
newvalue
|
425
435
|
end
|
426
436
|
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
437
|
+
@users_ou = new
|
438
|
+
|
439
|
+
container&.should_update
|
440
|
+
end
|
441
|
+
|
442
|
+
# An OU path for specific User Groups
|
443
|
+
#
|
444
|
+
# @author Tyler Morgan
|
445
|
+
#
|
446
|
+
# @param newvalue [String] The OU path for the specific user group
|
447
|
+
# @note Not sure what this is used for
|
448
|
+
#
|
449
|
+
# @raise [JSS::InvalidDataError] If the new value is not a String
|
450
|
+
#
|
451
|
+
# @return [void]
|
452
|
+
def groups_ou=(newvalue)
|
453
|
+
new =
|
454
|
+
if newvalue.to_s.empty?
|
455
|
+
JSS::BLANK
|
456
|
+
else
|
457
|
+
# Data Check
|
458
|
+
raise JSS::InvalidDataError, 'groups_ou must be either a string or nil.' unless newvalue.is_a? String || newvalue.nil?
|
459
|
+
|
460
|
+
newvalue
|
445
461
|
end
|
446
462
|
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
463
|
+
@groups_ou = new
|
464
|
+
|
465
|
+
container&.should_update
|
466
|
+
end
|
467
|
+
|
468
|
+
# An OU path for specific Printers
|
469
|
+
#
|
470
|
+
# @author Tyler Morgan
|
471
|
+
#
|
472
|
+
# @param newvalue [String] The OU path for the specific printer
|
473
|
+
# @note Not sure what this is used for
|
474
|
+
#
|
475
|
+
# @raise [JSS::InvalidDataError] If the new value is not a String
|
476
|
+
#
|
477
|
+
# @return [void]
|
478
|
+
def printers_ou=(newvalue)
|
479
|
+
new =
|
480
|
+
if newvalue.to_s.empty?
|
481
|
+
JSS::BLANK
|
482
|
+
else
|
483
|
+
# Data Check
|
484
|
+
raise JSS::InvalidDataError, 'printers_ou must be either a string or nil.' unless newvalue.is_a? String || newvalue.nil?
|
485
|
+
|
486
|
+
newvalue
|
468
487
|
end
|
469
488
|
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
489
|
+
@printers_ou = new
|
490
|
+
|
491
|
+
container&.should_update
|
492
|
+
end
|
493
|
+
|
494
|
+
# An OU path for specific shared folders
|
495
|
+
#
|
496
|
+
# @author Tyler Morgan
|
497
|
+
#
|
498
|
+
# @param newvalue [String] The OU path for the specific shared folders
|
499
|
+
# @note Not sure what this is used for
|
500
|
+
#
|
501
|
+
# @raise [JSS::InvalidDataError] If the new value is not a String
|
502
|
+
#
|
503
|
+
# @return [void]
|
504
|
+
def shared_folders_ou=(newvalue)
|
505
|
+
new =
|
506
|
+
if newvalue.to_s.empty?
|
507
|
+
JSS::BLANK
|
508
|
+
else
|
509
|
+
# Data Check
|
510
|
+
raise JSS::InvalidDataError, 'shared_folders_ou must be either a string or nil.' unless newvalue.is_a? String || newvalue.nil?
|
511
|
+
|
512
|
+
newvalue
|
491
513
|
end
|
492
514
|
|
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
|
-
|
515
|
+
@shared_folders_ou = new
|
516
|
+
|
517
|
+
container&.should_update
|
518
|
+
end
|
519
|
+
|
520
|
+
# An a specific admin group to admin_group
|
521
|
+
#
|
522
|
+
# @author Tyler Morgan
|
523
|
+
#
|
524
|
+
# @param value [String] The admin group name you wish to add to the admin group list
|
525
|
+
#
|
526
|
+
# @raise [JSS::InvalidDataError] If the value provided is not a String
|
527
|
+
# @raise [JSS::InvalidDataError] If the group provided is already a member of the admin_group array
|
528
|
+
#
|
529
|
+
# @return [Array <String>] An array of all the admin groups currently set.
|
530
|
+
def add_admin_group(value)
|
531
|
+
raise JSS::InvalidDataError, 'Admin group must be a string.' unless value.is_a? String
|
532
|
+
raise JSS::InvalidDataError, "Admin group \"#{value}\" already is in the list of admin groups." if @admin_group.include? value
|
533
|
+
|
534
|
+
@admin_group << value
|
535
|
+
|
536
|
+
container&.should_update
|
537
|
+
|
538
|
+
@admin_group
|
539
|
+
end
|
540
|
+
|
541
|
+
# Remove a specific admin group to admin_group
|
542
|
+
#
|
543
|
+
# @author Tyler Morgan
|
544
|
+
#
|
545
|
+
# @param newvalue [String] The admin group name you wish to remove from the admin group list
|
546
|
+
#
|
547
|
+
# @raise [JSS::InvalidDataError] If the value provided is not a String
|
548
|
+
# @raise [JSS::InvalidDataError] If the group provided is not in the admin_group array
|
549
|
+
#
|
550
|
+
# @return [Array <String>] An array of all the admin groups currently set.
|
551
|
+
def remove_admin_group(value)
|
552
|
+
raise JSS::InvalidDataError, 'Admin group being removed must be a string' unless value.is_a? String
|
553
|
+
raise JSS::InvalidDataError, "Admin group #{value} is not in the current admin group(s)." unless @admin_group.include? value
|
554
|
+
|
555
|
+
@admin_group.delete value
|
556
|
+
|
557
|
+
container&.should_update
|
558
|
+
|
559
|
+
@admin_group
|
560
|
+
end
|
561
|
+
|
562
|
+
# Return a REXML Element containing the current state of the DirectoryBindingType
|
563
|
+
# object for adding into the XML of the container.
|
564
|
+
#
|
565
|
+
# @author Tyler Morgan
|
566
|
+
#
|
567
|
+
# @return [REXML::Element]
|
568
|
+
def type_setting_xml
|
569
|
+
type_setting = REXML::Element.new 'admitmac'
|
570
|
+
type_setting.add_element('require_confirmation').text = @require_confirmation
|
571
|
+
type_setting.add_element('local_home').text = @local_home
|
572
|
+
type_setting.add_element('mount_style').text = @mount_style.downcase
|
573
|
+
type_setting.add_element('default_shell').text = @default_shell
|
574
|
+
type_setting.add_element('mount_network_home').text = @mount_network_home
|
575
|
+
type_setting.add_element('place_home_folders').text = @place_home_folders
|
576
|
+
type_setting.add_element('uid').text = @uid
|
577
|
+
type_setting.add_element('user_gid').text = @user_gid
|
578
|
+
type_setting.add_element('gid').text = @gid
|
579
|
+
type_setting.add_element('add_user_to_local').text = @add_user_to_local
|
580
|
+
type_setting.add_element('cached_credentials').text = @cached_credentials
|
581
|
+
type_setting.add_element('users_ou').text = @users_ou
|
582
|
+
type_setting.add_element('groups_ou').text = @groups_ou
|
583
|
+
type_setting.add_element('printers_ou').text = @printers_ou
|
584
|
+
type_setting.add_element('shared_folders_ou').text = @shared_folders_ou
|
585
|
+
type_setting.add_element('admin_group').text = @admin_group.join(',').to_s unless @admin_group.nil?
|
586
|
+
|
587
|
+
type_setting
|
588
|
+
end
|
522
589
|
|
523
590
|
end
|
524
591
|
|
525
|
-
end
|
592
|
+
end
|
593
|
+
|
594
|
+
end
|