open_directory_utils 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +17 -5
- data/examples/create_od_users.rb +1 -1
- data/examples/relations.yml +48 -0
- data/examples/update_relationship.rb +48 -0
- data/lib/open_directory_utils/clean_check.rb +4 -4
- data/lib/open_directory_utils/commands_base.rb +9 -5
- data/lib/open_directory_utils/{commands_group_create_remove.rb → commands_groups.rb} +2 -43
- data/lib/open_directory_utils/commands_user_attribs.rb +437 -20
- data/lib/open_directory_utils/commands_user_create_remove.rb +71 -349
- data/lib/open_directory_utils/connection.rb +3 -4
- data/lib/open_directory_utils/version.rb +1 -1
- metadata +5 -3
@@ -14,6 +14,382 @@ module OpenDirectoryUtils
|
|
14
14
|
include OpenDirectoryUtils::CleanCheck
|
15
15
|
include OpenDirectoryUtils::CommandsBase
|
16
16
|
|
17
|
+
# GET INFO
|
18
|
+
##########
|
19
|
+
# get user record -- dscl . -read /Users/<username>
|
20
|
+
# get user value -- dscl . -read /Users/<username> <key>
|
21
|
+
# search od user -- dscl . -search /Users RealName "Andrew Garrett"
|
22
|
+
# return as xml -- dscl -plist . -search /Users RealName "Andrew Garrett"
|
23
|
+
def user_get_info(attribs, dir_info)
|
24
|
+
attribs = user_record_name_alternatives(attribs)
|
25
|
+
|
26
|
+
check_critical_attribute( attribs, :record_name )
|
27
|
+
attribs = tidy_attribs(attribs)
|
28
|
+
|
29
|
+
command = {action: 'read', scope: 'Users', attribute: nil, value: nil}
|
30
|
+
user_attrs = attribs.merge(command)
|
31
|
+
|
32
|
+
answer = dscl( user_attrs, dir_info )
|
33
|
+
attribs[:value] = nil
|
34
|
+
return answer
|
35
|
+
end
|
36
|
+
alias_method :user_info, :user_get_info
|
37
|
+
|
38
|
+
# get all usernames -- dscl . -list /Users
|
39
|
+
# get all user details -- dscl . -readall /Users
|
40
|
+
def user_exists?(attribs, dir_info)
|
41
|
+
user_get_info(attribs, dir_info)
|
42
|
+
end
|
43
|
+
|
44
|
+
# CHANGE OD
|
45
|
+
###########
|
46
|
+
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$USER RealName "$VALUE"
|
47
|
+
def user_set_real_name(attribs, dir_info)
|
48
|
+
attribs = user_record_name_alternatives(attribs)
|
49
|
+
|
50
|
+
attribs[:value] = attribs[:value] || attribs[:common_name]
|
51
|
+
attribs[:value] = attribs[:value] || attribs[:cn]
|
52
|
+
attribs[:value] = attribs[:value] || attribs[:realname]
|
53
|
+
attribs[:value] = attribs[:value] || attribs[:real_name]
|
54
|
+
attribs[:value] = attribs[:value] || attribs[:fullname]
|
55
|
+
attribs[:value] = attribs[:value] || attribs[:full_name]
|
56
|
+
if attribs[:last_name] or attribs[:first_name]
|
57
|
+
attribs[:value] = attribs[:value] || "#{attribs[:first_name]} #{attribs[:last_name]}"
|
58
|
+
end
|
59
|
+
attribs[:value] = attribs[:value] || attribs[:record_name]
|
60
|
+
|
61
|
+
check_critical_attribute( attribs, :record_name )
|
62
|
+
check_critical_attribute( attribs, :value, :real_name )
|
63
|
+
attribs = tidy_attribs(attribs)
|
64
|
+
|
65
|
+
command = {action: 'create', scope: 'Users', attribute: 'RealName'}
|
66
|
+
user_attrs = attribs.merge(command)
|
67
|
+
|
68
|
+
answer = dscl( user_attrs, dir_info )
|
69
|
+
attribs[:value] = nil
|
70
|
+
return answer
|
71
|
+
end
|
72
|
+
|
73
|
+
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$shortname_USERNAME FirstName "$VALUE"
|
74
|
+
def user_set_first_name(attribs, dir_info)
|
75
|
+
attribs = user_record_name_alternatives(attribs)
|
76
|
+
|
77
|
+
attribs[:value] = attribs[:value] || attribs[:given_name]
|
78
|
+
attribs[:value] = attribs[:value] || attribs[:givenname]
|
79
|
+
attribs[:value] = attribs[:value] || attribs[:first_name]
|
80
|
+
attribs[:value] = attribs[:value] || attribs[:firstname]
|
81
|
+
|
82
|
+
check_critical_attribute( attribs, :record_name )
|
83
|
+
check_critical_attribute( attribs, :value, :first_name )
|
84
|
+
attribs = tidy_attribs(attribs)
|
85
|
+
|
86
|
+
command = {action: 'create', scope: 'Users', attribute: 'FirstName'}
|
87
|
+
user_attrs = attribs.merge(command)
|
88
|
+
|
89
|
+
answer = dscl( user_attrs, dir_info )
|
90
|
+
attribs[:value] = nil
|
91
|
+
return answer
|
92
|
+
end
|
93
|
+
|
94
|
+
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$shortname_USERNAME LastName "$VALUE"
|
95
|
+
def user_set_last_name(attribs, dir_info)
|
96
|
+
attribs = user_record_name_alternatives(attribs)
|
97
|
+
|
98
|
+
attribs[:value] = attribs[:value] || attribs[:sn]
|
99
|
+
attribs[:value] = attribs[:value] || attribs[:surname]
|
100
|
+
attribs[:value] = attribs[:value] || attribs[:lastname]
|
101
|
+
attribs[:value] = attribs[:value] || attribs[:last_name]
|
102
|
+
attribs[:value] = attribs[:value] || attribs[:real_name]
|
103
|
+
attribs[:value] = attribs[:value] || attribs[:realname]
|
104
|
+
attribs[:value] = attribs[:value] || attribs[:short_name]
|
105
|
+
attribs[:value] = attribs[:value] || attribs[:shortname]
|
106
|
+
attribs[:value] = attribs[:value] || attribs[:user_name]
|
107
|
+
attribs[:value] = attribs[:value] || attribs[:username]
|
108
|
+
attribs[:value] = attribs[:value] || attribs[:uid]
|
109
|
+
|
110
|
+
check_critical_attribute( attribs, :record_name )
|
111
|
+
check_critical_attribute( attribs, :value, :last_name )
|
112
|
+
attribs = tidy_attribs(attribs)
|
113
|
+
|
114
|
+
command = {action: 'create', scope: 'Users', attribute: 'LastName'}
|
115
|
+
user_attrs = attribs.merge(command)
|
116
|
+
|
117
|
+
answer = dscl( user_attrs, dir_info )
|
118
|
+
attribs[:value] = nil
|
119
|
+
return answer
|
120
|
+
end
|
121
|
+
|
122
|
+
# sudo dscl . -create /Users/someuser UniqueID "1010"
|
123
|
+
def user_set_unique_id(attribs, dir_info)
|
124
|
+
attribs = user_record_name_alternatives(attribs)
|
125
|
+
check_critical_attribute( attribs, :record_name )
|
126
|
+
|
127
|
+
attribs[:value] = attribs[:value] || attribs[:uniqueid]
|
128
|
+
attribs[:value] = attribs[:value] || attribs[:unique_id]
|
129
|
+
attribs[:value] = attribs[:value] || attribs[:uid_number]
|
130
|
+
attribs[:value] = attribs[:value] || attribs[:uidnumber]
|
131
|
+
attribs[:value] = attribs[:value] || attribs[:usernumber]
|
132
|
+
attribs[:value] = attribs[:value] || attribs[:user_number]
|
133
|
+
|
134
|
+
check_critical_attribute( attribs, :value, :unique_id )
|
135
|
+
attribs = tidy_attribs(attribs)
|
136
|
+
|
137
|
+
command = {action: 'create', scope: 'Users', attribute: 'UniqueID'}
|
138
|
+
user_attrs = attribs.merge(command)
|
139
|
+
|
140
|
+
# dscl( user_attrs, dir_info )
|
141
|
+
answer = dscl( user_attrs, dir_info )
|
142
|
+
attribs[:value] = nil
|
143
|
+
return answer
|
144
|
+
end
|
145
|
+
|
146
|
+
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/someuser NFSHomeDirectory /Users/someuser
|
147
|
+
def user_set_nfs_home_directory(attribs, dir_info)
|
148
|
+
attribs = user_record_name_alternatives(attribs)
|
149
|
+
|
150
|
+
attribs[:value] = attribs[:value] || attribs[:home_directory]
|
151
|
+
attribs[:value] = attribs[:value] || attribs[:nfs_home_directory]
|
152
|
+
attribs[:value] = attribs[:value] || '/Volumes/Macintosh HD/Users/someone'
|
153
|
+
|
154
|
+
check_critical_attribute( attribs, :record_name )
|
155
|
+
check_critical_attribute( attribs, :value, :home_directory )
|
156
|
+
attribs = tidy_attribs(attribs)
|
157
|
+
|
158
|
+
command = {action: 'create', scope: 'Users', attribute: 'NFSHomeDirectory'}
|
159
|
+
user_attrs = attribs.merge(command)
|
160
|
+
|
161
|
+
answer = dscl( user_attrs, dir_info )
|
162
|
+
attribs[:value] = nil
|
163
|
+
return answer
|
164
|
+
end
|
165
|
+
|
166
|
+
# sudo dscl . -create /Users/someuser UserShell /bin/bash
|
167
|
+
def user_set_shell(attribs, dir_info)
|
168
|
+
attribs = user_record_name_alternatives(attribs)
|
169
|
+
|
170
|
+
attribs[:value] = attribs[:value] || attribs[:user_shell]
|
171
|
+
attribs[:value] = attribs[:value] || attribs[:shell]
|
172
|
+
attribs[:value] = attribs[:value] || '/bin/bash'
|
173
|
+
|
174
|
+
check_critical_attribute( attribs, :record_name )
|
175
|
+
check_critical_attribute( attribs, :value, :shell )
|
176
|
+
attribs = tidy_attribs(attribs)
|
177
|
+
|
178
|
+
command = {action: 'create', scope: 'Users', attribute: 'UserShell'}
|
179
|
+
user_attrs = attribs.merge(command)
|
180
|
+
|
181
|
+
answer = dscl( user_attrs, dir_info )
|
182
|
+
attribs[:value] = nil
|
183
|
+
return answer
|
184
|
+
end
|
185
|
+
|
186
|
+
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$shortname_USERNAME mail "$VALUE"
|
187
|
+
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$shortname_USERNAME email "$VALUE"
|
188
|
+
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$shortname_USERNAME apple-user-mailattribute "$VALUE"
|
189
|
+
def user_set_first_email(attribs, dir_info)
|
190
|
+
attribs = user_record_name_alternatives(attribs)
|
191
|
+
|
192
|
+
attribs[:value] = attribs[:value] || attribs['apple-user-mailattribute']
|
193
|
+
attribs[:value] = attribs[:value] || attribs[:apple_user_mailattribute]
|
194
|
+
attribs[:value] = attribs[:value] || attribs[:email]
|
195
|
+
attribs[:value] = attribs[:value] || attribs[:mail]
|
196
|
+
|
197
|
+
check_critical_attribute( attribs, :record_name )
|
198
|
+
check_critical_attribute( attribs, :value, :email )
|
199
|
+
attribs = tidy_attribs(attribs)
|
200
|
+
|
201
|
+
answer = []
|
202
|
+
|
203
|
+
command = {action: 'create', scope: 'Users', attribute: 'MailAttribute'}
|
204
|
+
user_attrs = attribs.merge(command)
|
205
|
+
answer << dscl( user_attrs, dir_info )
|
206
|
+
|
207
|
+
command = {action: 'create', scope: 'Users', attribute: 'EMailAddress'}
|
208
|
+
user_attrs = attribs.merge(command)
|
209
|
+
answer << dscl( user_attrs, dir_info )
|
210
|
+
|
211
|
+
# command = {action: 'create', scope: 'Users', attribute: 'apple-user-mailattribute'}
|
212
|
+
# user_attrs = attribs.merge(command)
|
213
|
+
# answer << dscl( user_attrs, dir_info )
|
214
|
+
attribs[:value] = nil
|
215
|
+
return answer
|
216
|
+
end
|
217
|
+
alias_method :user_set_email, :user_set_first_email
|
218
|
+
|
219
|
+
def user_append_email(attribs, dir_info)
|
220
|
+
attribs = user_record_name_alternatives(attribs)
|
221
|
+
|
222
|
+
attribs[:value] = attribs[:value] || attribs['apple-user-mailattribute']
|
223
|
+
attribs[:value] = attribs[:value] || attribs[:apple_user_mailattribute]
|
224
|
+
attribs[:value] = attribs[:value] || attribs[:e_mail_attribute]
|
225
|
+
attribs[:value] = attribs[:value] || attribs[:mail_attribute]
|
226
|
+
attribs[:value] = attribs[:value] || attribs[:email]
|
227
|
+
attribs[:value] = attribs[:value] || attribs[:mail]
|
228
|
+
|
229
|
+
check_critical_attribute( attribs, :record_name )
|
230
|
+
check_critical_attribute( attribs, :value, :email )
|
231
|
+
attribs = tidy_attribs(attribs)
|
232
|
+
|
233
|
+
answer = []
|
234
|
+
|
235
|
+
# command = {action: 'append', scope: 'Users', attribute: 'mail'}
|
236
|
+
# user_attrs = attribs.merge(command)
|
237
|
+
# answer << dscl( user_attrs, dir_info )
|
238
|
+
|
239
|
+
command = {action: 'append', scope: 'Users', attribute: 'email'}
|
240
|
+
user_attrs = attribs.merge(command)
|
241
|
+
answer << dscl( user_attrs, dir_info )
|
242
|
+
|
243
|
+
attribs[:value] = nil
|
244
|
+
return answer
|
245
|
+
end
|
246
|
+
|
247
|
+
# sudo dscl . -create /Users/someuser PrimaryGroupID 80
|
248
|
+
def user_set_primary_group_id(attribs, dir_info)
|
249
|
+
attribs = user_record_name_alternatives(attribs)
|
250
|
+
|
251
|
+
attribs[:value] = attribs[:value] || attribs[:groupid]
|
252
|
+
attribs[:value] = attribs[:value] || attribs[:group_id]
|
253
|
+
attribs[:value] = attribs[:value] || attribs[:gidnumber]
|
254
|
+
attribs[:value] = attribs[:value] || attribs[:groupnumber]
|
255
|
+
attribs[:value] = attribs[:value] || attribs[:group_number]
|
256
|
+
attribs[:value] = attribs[:value] || attribs[:primarygroupid]
|
257
|
+
attribs[:value] = attribs[:value] || attribs[:primary_group_id]
|
258
|
+
|
259
|
+
check_critical_attribute( attribs, :record_name )
|
260
|
+
check_critical_attribute( attribs, :value, :group_id )
|
261
|
+
attribs = tidy_attribs(attribs)
|
262
|
+
|
263
|
+
command = {action: 'create', scope: 'Users', attribute: 'PrimaryGroupID'}
|
264
|
+
user_attrs = attribs.merge(command)
|
265
|
+
|
266
|
+
answer = dscl( user_attrs, dir_info )
|
267
|
+
attribs[:value] = nil
|
268
|
+
return answer
|
269
|
+
end
|
270
|
+
|
271
|
+
# /usr/bin/pwpolicy -a diradmin -p "TopSecret" -u username -setpassword "AnotherSecret"
|
272
|
+
# /usr/bin/dscl -plist -u diradmin -P #{adminpw} /LDAPv3/127.0.0.1 -passwd /Users/#{shortname} "#{passwd}"
|
273
|
+
def user_set_password(attribs, dir_info)
|
274
|
+
attribs = user_record_name_alternatives(attribs)
|
275
|
+
|
276
|
+
attribs[:value] = attribs[:value] || attribs[:password]
|
277
|
+
attribs[:value] = attribs[:value] || attribs[:passwd]
|
278
|
+
attribs[:value] = attribs[:value] || '*'
|
279
|
+
|
280
|
+
check_critical_attribute( attribs, :record_name )
|
281
|
+
check_critical_attribute( attribs, :value, :password )
|
282
|
+
attribs = tidy_attribs(attribs)
|
283
|
+
|
284
|
+
command = {action: 'passwd', scope: 'Users'}
|
285
|
+
user_attrs = attribs.merge(command)
|
286
|
+
|
287
|
+
answer = dscl( user_attrs, dir_info )
|
288
|
+
attribs[:value] = nil
|
289
|
+
return answer
|
290
|
+
end
|
291
|
+
# /usr/bin/dscl /LDAPv3/127.0.0.1 -auth #{shortname} "#{passwd}"
|
292
|
+
def user_password_verified?(attribs, dir_info)
|
293
|
+
attribs = user_record_name_alternatives(attribs)
|
294
|
+
|
295
|
+
attribs[:value] = attribs[:value] || attribs[:password]
|
296
|
+
attribs[:value] = attribs[:value] || attribs[:passwd]
|
297
|
+
|
298
|
+
check_critical_attribute( attribs, :record_name )
|
299
|
+
check_critical_attribute( attribs, :value, :password )
|
300
|
+
attribs = tidy_attribs(attribs)
|
301
|
+
|
302
|
+
command = {action: 'auth', scope: 'Users'}
|
303
|
+
user_attrs = attribs.merge(command)
|
304
|
+
|
305
|
+
answer = dscl( user_attrs, dir_info )
|
306
|
+
attribs[:value] = nil
|
307
|
+
return answer
|
308
|
+
end
|
309
|
+
alias_method :user_password_ok?, :user_password_verified?
|
310
|
+
|
311
|
+
# /usr/bin/pwpolicy -a diradmin -p A-B1g-S3cret -u $shortname_USERNAME -setpolicy "isDisabled=0"
|
312
|
+
def user_enable_login(attribs, dir_info)
|
313
|
+
attribs = user_record_name_alternatives(attribs)
|
314
|
+
|
315
|
+
check_critical_attribute( attribs, :record_name )
|
316
|
+
attribs = tidy_attribs(attribs)
|
317
|
+
|
318
|
+
command = {attribute: 'enableuser', value: nil}
|
319
|
+
params = command.merge(attribs)
|
320
|
+
pwpolicy(params, dir_info)
|
321
|
+
end
|
322
|
+
# /usr/bin/pwpolicy -a diradmin -p A-B1g-S3cret -u $shortname_USERNAME -setpolicy "isDisabled=1"
|
323
|
+
def user_disable_login(attribs, dir_info)
|
324
|
+
attribs = user_record_name_alternatives(attribs)
|
325
|
+
|
326
|
+
check_critical_attribute( attribs, :record_name )
|
327
|
+
attribs = tidy_attribs(attribs)
|
328
|
+
|
329
|
+
command = {attribute: 'disableuser', value: nil}
|
330
|
+
params = command.merge(attribs)
|
331
|
+
# pwpolicy(params, dir_info)
|
332
|
+
answer = pwpolicy(params, dir_info)
|
333
|
+
attribs[:value] = nil
|
334
|
+
return answer
|
335
|
+
end
|
336
|
+
|
337
|
+
def user_add_to_group(attribs, dir_info)
|
338
|
+
attribs = user_record_name_alternatives(attribs)
|
339
|
+
|
340
|
+
attribs[:value] = attribs[:group_membership]
|
341
|
+
attribs[:value] = attribs[:value] || attribs[:groupmembership]
|
342
|
+
attribs[:value] = attribs[:value] || attribs[:group_name]
|
343
|
+
attribs[:value] = attribs[:value] || attribs[:groupname]
|
344
|
+
attribs[:value] = attribs[:value] || attribs[:gid]
|
345
|
+
|
346
|
+
check_critical_attribute( attribs, :record_name, :username )
|
347
|
+
check_critical_attribute( attribs, :value, :groupname )
|
348
|
+
attribs = tidy_attribs(attribs)
|
349
|
+
command = { operation: 'edit', action: 'add', type: 'user'}
|
350
|
+
user_attrs = attribs.merge(command)
|
351
|
+
|
352
|
+
answer = dseditgroup( user_attrs, dir_info )
|
353
|
+
attribs[:value] = nil
|
354
|
+
return answer
|
355
|
+
end
|
356
|
+
|
357
|
+
def user_remove_from_group(attribs, dir_info)
|
358
|
+
attribs = user_record_name_alternatives(attribs)
|
359
|
+
|
360
|
+
attribs[:value] = attribs[:group_membership]
|
361
|
+
attribs[:value] = attribs[:value] || attribs[:groupmembership]
|
362
|
+
attribs[:value] = attribs[:value] || attribs[:group_name]
|
363
|
+
attribs[:value] = attribs[:value] || attribs[:groupname]
|
364
|
+
attribs[:value] = attribs[:value] || attribs[:gid]
|
365
|
+
|
366
|
+
check_critical_attribute( attribs, :record_name, :username )
|
367
|
+
check_critical_attribute( attribs, :value, :groupname )
|
368
|
+
attribs = tidy_attribs(attribs)
|
369
|
+
command = { operation: 'edit', action: 'delete', type: 'user'}
|
370
|
+
user_attrs = attribs.merge(command)
|
371
|
+
|
372
|
+
answer = dseditgroup( user_attrs, dir_info )
|
373
|
+
attribs[:value] = nil
|
374
|
+
return answer
|
375
|
+
end
|
376
|
+
|
377
|
+
# /usr/bin/pwpolicy -a diradmin -p A-B1g-S3cret -u $shortname_USERNAME -getpolicy
|
378
|
+
def user_get_policy(attribs, dir_info)
|
379
|
+
attribs = user_record_name_alternatives(attribs)
|
380
|
+
|
381
|
+
check_critical_attribute( attribs, :record_name )
|
382
|
+
attribs = tidy_attribs(attribs)
|
383
|
+
|
384
|
+
command = {attribute: 'getpolicy', value: nil}
|
385
|
+
params = command.merge(attribs)
|
386
|
+
|
387
|
+
answer = pwpolicy(params, dir_info)
|
388
|
+
attribs[:value] = nil
|
389
|
+
return answer
|
390
|
+
end
|
391
|
+
alias_method :user_login_enabled?, :user_get_policy
|
392
|
+
|
17
393
|
def user_set_city(attribs, dir_info)
|
18
394
|
attribs = user_record_name_alternatives(attribs)
|
19
395
|
check_critical_attribute( attribs, :record_name )
|
@@ -29,7 +405,9 @@ module OpenDirectoryUtils
|
|
29
405
|
command = {action: 'create', scope: 'Users', attribute: 'City'}
|
30
406
|
user_attrs = attribs.merge(command)
|
31
407
|
|
32
|
-
dscl( user_attrs, dir_info )
|
408
|
+
answer = dscl( user_attrs, dir_info )
|
409
|
+
attribs[:value] = nil
|
410
|
+
return answer
|
33
411
|
end
|
34
412
|
|
35
413
|
# first - /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$USER apple-imhandle "$VALUE"
|
@@ -50,7 +428,9 @@ module OpenDirectoryUtils
|
|
50
428
|
command = {action: 'create', scope: 'Users', attribute: 'IMHandle'}
|
51
429
|
user_attrs = attribs.merge(command)
|
52
430
|
|
53
|
-
dscl( user_attrs, dir_info )
|
431
|
+
answer = dscl( user_attrs, dir_info )
|
432
|
+
attribs[:value] = nil
|
433
|
+
return answer
|
54
434
|
end
|
55
435
|
|
56
436
|
# first - /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$USER apple-imhandle "$VALUE"
|
@@ -71,7 +451,9 @@ module OpenDirectoryUtils
|
|
71
451
|
command = {action: 'append', scope: 'Users', attribute: 'IMHandle'}
|
72
452
|
user_attrs = attribs.merge(command)
|
73
453
|
|
74
|
-
dscl( user_attrs, dir_info )
|
454
|
+
answer = dscl( user_attrs, dir_info )
|
455
|
+
attribs[:value] = nil
|
456
|
+
return answer
|
75
457
|
end
|
76
458
|
|
77
459
|
# first - /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$USER apple-imhandle "$VALUE"
|
@@ -99,6 +481,7 @@ module OpenDirectoryUtils
|
|
99
481
|
answer << user_append_chat(attribs, dir_info)
|
100
482
|
end
|
101
483
|
end
|
484
|
+
attribs[:value] = nil
|
102
485
|
return answer unless attribs[:values].nil? or attribs[:values].empty?
|
103
486
|
raise ArgumentError, "values: '#{attribs[:values].inspect}' invalid, value_name: :chats"
|
104
487
|
end
|
@@ -122,7 +505,9 @@ module OpenDirectoryUtils
|
|
122
505
|
command = {action: 'create', scope: 'Users', attribute: 'Comment'}
|
123
506
|
user_attrs = attribs.merge(command)
|
124
507
|
|
125
|
-
dscl( user_attrs, dir_info )
|
508
|
+
answer = dscl( user_attrs, dir_info )
|
509
|
+
attribs[:value] = nil
|
510
|
+
return answer
|
126
511
|
end
|
127
512
|
alias_method :user_set_description, :user_set_comment
|
128
513
|
|
@@ -139,7 +524,9 @@ module OpenDirectoryUtils
|
|
139
524
|
command = {action: 'create', scope: 'Users', attribute: 'Company'}
|
140
525
|
user_attrs = attribs.merge(command)
|
141
526
|
|
142
|
-
dscl( user_attrs, dir_info )
|
527
|
+
answer = dscl( user_attrs, dir_info )
|
528
|
+
attribs[:value] = nil
|
529
|
+
return answer
|
143
530
|
end
|
144
531
|
# alias_method :las_program_info, :user_set_company
|
145
532
|
|
@@ -156,7 +543,9 @@ module OpenDirectoryUtils
|
|
156
543
|
command = {action: 'create', scope: 'Users', attribute: 'Country'}
|
157
544
|
user_attrs = attribs.merge(command)
|
158
545
|
|
159
|
-
dscl( user_attrs, dir_info )
|
546
|
+
answer = dscl( user_attrs, dir_info )
|
547
|
+
attribs[:value] = nil
|
548
|
+
return answer
|
160
549
|
end
|
161
550
|
|
162
551
|
def user_set_department(attribs, dir_info)
|
@@ -176,7 +565,9 @@ module OpenDirectoryUtils
|
|
176
565
|
command = {action: 'create', scope: 'Users', attribute: 'Department'}
|
177
566
|
user_attrs = attribs.merge(command)
|
178
567
|
|
179
|
-
dscl( user_attrs, dir_info )
|
568
|
+
answer = dscl( user_attrs, dir_info )
|
569
|
+
attribs[:value] = nil
|
570
|
+
return answer
|
180
571
|
end
|
181
572
|
|
182
573
|
def user_set_job_title(attribs, dir_info)
|
@@ -193,7 +584,9 @@ module OpenDirectoryUtils
|
|
193
584
|
command = {action: 'create', scope: 'Users', attribute: 'JobTitle'}
|
194
585
|
user_attrs = attribs.merge(command)
|
195
586
|
|
196
|
-
dscl( user_attrs, dir_info )
|
587
|
+
answer = dscl( user_attrs, dir_info )
|
588
|
+
attribs[:value] = nil
|
589
|
+
return answer
|
197
590
|
end
|
198
591
|
alias_method :user_set_title, :user_set_job_title
|
199
592
|
|
@@ -212,7 +605,9 @@ module OpenDirectoryUtils
|
|
212
605
|
command = {action: 'create', scope: 'Users', attribute: 'Keywords'}
|
213
606
|
user_attrs = attribs.merge(command)
|
214
607
|
|
215
|
-
dscl( user_attrs, dir_info )
|
608
|
+
answer = dscl( user_attrs, dir_info )
|
609
|
+
attribs[:value] = nil
|
610
|
+
return answer
|
216
611
|
end
|
217
612
|
alias_method :user_create_keywords, :user_create_keyword
|
218
613
|
|
@@ -230,7 +625,9 @@ module OpenDirectoryUtils
|
|
230
625
|
command = {action: 'append', scope: 'Users', attribute: 'Keywords'}
|
231
626
|
user_attrs = attribs.merge(command)
|
232
627
|
|
233
|
-
dscl( user_attrs, dir_info )
|
628
|
+
answer = dscl( user_attrs, dir_info )
|
629
|
+
attribs[:value] = nil
|
630
|
+
return answer
|
234
631
|
end
|
235
632
|
alias_method :user_append_keywords, :user_append_keyword
|
236
633
|
|
@@ -273,7 +670,9 @@ module OpenDirectoryUtils
|
|
273
670
|
command = {action: 'create', scope: 'Users', attribute: 'HomePhoneNumber'}
|
274
671
|
user_attrs = attribs.merge(command)
|
275
672
|
|
276
|
-
dscl( user_attrs, dir_info )
|
673
|
+
answer = dscl( user_attrs, dir_info )
|
674
|
+
attribs[:value] = nil
|
675
|
+
return answer
|
277
676
|
end
|
278
677
|
|
279
678
|
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -append /Users/$shortname_USERNAME apple-keyword "$VALUE"
|
@@ -291,7 +690,9 @@ module OpenDirectoryUtils
|
|
291
690
|
command = {action: 'create', scope: 'Users', attribute: 'MobileNumber'}
|
292
691
|
user_attrs = attribs.merge(command)
|
293
692
|
|
294
|
-
dscl( user_attrs, dir_info )
|
693
|
+
answer = dscl( user_attrs, dir_info )
|
694
|
+
attribs[:value] = nil
|
695
|
+
return answer
|
295
696
|
end
|
296
697
|
alias_method :user_set_mobile_number, :user_set_mobile_phone
|
297
698
|
alias_method :user_set_mobile_phone_number, :user_set_mobile_phone
|
@@ -314,7 +715,9 @@ module OpenDirectoryUtils
|
|
314
715
|
command = {action: 'create', scope: 'Users', attribute: 'PhoneNumber'}
|
315
716
|
user_attrs = attribs.merge(command)
|
316
717
|
|
317
|
-
dscl( user_attrs, dir_info )
|
718
|
+
answer = dscl( user_attrs, dir_info )
|
719
|
+
attribs[:value] = nil
|
720
|
+
return answer
|
318
721
|
end
|
319
722
|
|
320
723
|
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -append /Users/$shortname_USERNAME apple-keyword "$VALUE"
|
@@ -330,7 +733,9 @@ module OpenDirectoryUtils
|
|
330
733
|
command = {action: 'create', scope: 'Users', attribute: 'NameSuffix'}
|
331
734
|
user_attrs = attribs.merge(command)
|
332
735
|
|
333
|
-
dscl( user_attrs, dir_info )
|
736
|
+
answer = dscl( user_attrs, dir_info )
|
737
|
+
attribs[:value] = nil
|
738
|
+
return answer
|
334
739
|
end
|
335
740
|
|
336
741
|
def user_set_organization_info(attribs, dir_info)
|
@@ -347,7 +752,9 @@ module OpenDirectoryUtils
|
|
347
752
|
command = {action: 'create', scope: 'Users', attribute: 'OrganizationInfo'}
|
348
753
|
user_attrs = attribs.merge(command)
|
349
754
|
|
350
|
-
dscl( user_attrs, dir_info )
|
755
|
+
answer = dscl( user_attrs, dir_info )
|
756
|
+
attribs[:value] = nil
|
757
|
+
return answer
|
351
758
|
end
|
352
759
|
alias_method :user_set_org_info, :user_set_organization_info
|
353
760
|
# alias_method :user_set_student_id, :user_set_organization_info
|
@@ -367,7 +774,9 @@ module OpenDirectoryUtils
|
|
367
774
|
command = {action: 'create', scope: 'Users', attribute: 'PostalCode'}
|
368
775
|
user_attrs = attribs.merge(command)
|
369
776
|
|
370
|
-
dscl( user_attrs, dir_info )
|
777
|
+
answer = dscl( user_attrs, dir_info )
|
778
|
+
attribs[:value] = nil
|
779
|
+
return answer
|
371
780
|
end
|
372
781
|
alias_method :user_set_post_code, :user_set_postal_code
|
373
782
|
alias_method :user_set_zip_code, :user_set_postal_code
|
@@ -385,7 +794,9 @@ module OpenDirectoryUtils
|
|
385
794
|
command = {action: 'create', scope: 'Users', attribute: 'Relationships'}
|
386
795
|
user_attrs = attribs.merge(command)
|
387
796
|
|
388
|
-
dscl( user_attrs, dir_info )
|
797
|
+
answer = dscl( user_attrs, dir_info )
|
798
|
+
attribs[:value] = nil
|
799
|
+
return answer
|
389
800
|
end
|
390
801
|
|
391
802
|
def user_set_state(attribs, dir_info)
|
@@ -400,7 +811,9 @@ module OpenDirectoryUtils
|
|
400
811
|
command = {action: 'create', scope: 'Users', attribute: 'State'}
|
401
812
|
user_attrs = attribs.merge(command)
|
402
813
|
|
403
|
-
dscl( user_attrs, dir_info )
|
814
|
+
answer = dscl( user_attrs, dir_info )
|
815
|
+
attribs[:value] = nil
|
816
|
+
return answer
|
404
817
|
end
|
405
818
|
|
406
819
|
def user_set_street(attribs, dir_info)
|
@@ -415,7 +828,9 @@ module OpenDirectoryUtils
|
|
415
828
|
command = {action: 'create', scope: 'Users', attribute: 'Street'}
|
416
829
|
user_attrs = attribs.merge(command)
|
417
830
|
|
418
|
-
dscl( user_attrs, dir_info )
|
831
|
+
answer = dscl( user_attrs, dir_info )
|
832
|
+
attribs[:value] = nil
|
833
|
+
return answer
|
419
834
|
end
|
420
835
|
alias_method :user_set_address, :user_set_street
|
421
836
|
|
@@ -432,7 +847,9 @@ module OpenDirectoryUtils
|
|
432
847
|
command = {action: 'create', scope: 'Users', attribute: 'WeblogURI'}
|
433
848
|
user_attrs = attribs.merge(command)
|
434
849
|
|
435
|
-
dscl( user_attrs, dir_info )
|
850
|
+
answer = dscl( user_attrs, dir_info )
|
851
|
+
attribs[:value] = nil
|
852
|
+
return answer
|
436
853
|
end
|
437
854
|
alias_method :user_set_blog, :user_set_weblog
|
438
855
|
# alias_method :las_sync_date, :user_set_weblog
|