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
@@ -1,6 +1,8 @@
|
|
1
1
|
# require "open_directory_utils/dscl"
|
2
2
|
require "open_directory_utils/clean_check"
|
3
3
|
require "open_directory_utils/commands_base"
|
4
|
+
require "open_directory_utils/commands_groups"
|
5
|
+
require "open_directory_utils/commands_user_attribs"
|
4
6
|
|
5
7
|
module OpenDirectoryUtils
|
6
8
|
|
@@ -13,350 +15,8 @@ module OpenDirectoryUtils
|
|
13
15
|
# include OpenDirectoryUtils::Dscl
|
14
16
|
include OpenDirectoryUtils::CleanCheck
|
15
17
|
include OpenDirectoryUtils::CommandsBase
|
16
|
-
|
17
|
-
|
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
|
-
dscl( user_attrs, dir_info )
|
33
|
-
end
|
34
|
-
alias_method :user_info, :user_get_info
|
35
|
-
|
36
|
-
# get all usernames -- dscl . -list /Users
|
37
|
-
# get all user details -- dscl . -readall /Users
|
38
|
-
def user_exists?(attribs, dir_info)
|
39
|
-
user_get_info(attribs, dir_info)
|
40
|
-
end
|
41
|
-
|
42
|
-
# CHANGE OD
|
43
|
-
###########
|
44
|
-
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$USER RealName "$VALUE"
|
45
|
-
def user_set_real_name(attribs, dir_info)
|
46
|
-
attribs = user_record_name_alternatives(attribs)
|
47
|
-
|
48
|
-
attribs[:value] = attribs[:value] || attribs[:common_name]
|
49
|
-
attribs[:value] = attribs[:value] || attribs[:cn]
|
50
|
-
attribs[:value] = attribs[:value] || attribs[:realname]
|
51
|
-
attribs[:value] = attribs[:value] || attribs[:real_name]
|
52
|
-
attribs[:value] = attribs[:value] || attribs[:fullname]
|
53
|
-
attribs[:value] = attribs[:value] || attribs[:full_name]
|
54
|
-
if attribs[:last_name] or attribs[:first_name]
|
55
|
-
attribs[:value] = attribs[:value] || "#{attribs[:first_name]} #{attribs[:last_name]}"
|
56
|
-
end
|
57
|
-
attribs[:value] = attribs[:value] || attribs[:record_name]
|
58
|
-
|
59
|
-
check_critical_attribute( attribs, :record_name )
|
60
|
-
check_critical_attribute( attribs, :value, :real_name )
|
61
|
-
attribs = tidy_attribs(attribs)
|
62
|
-
|
63
|
-
command = {action: 'create', scope: 'Users', attribute: 'RealName'}
|
64
|
-
user_attrs = attribs.merge(command)
|
65
|
-
|
66
|
-
dscl( user_attrs, dir_info )
|
67
|
-
end
|
68
|
-
|
69
|
-
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$shortname_USERNAME FirstName "$VALUE"
|
70
|
-
def user_set_first_name(attribs, dir_info)
|
71
|
-
attribs = user_record_name_alternatives(attribs)
|
72
|
-
|
73
|
-
attribs[:value] = attribs[:value] || attribs[:given_name]
|
74
|
-
attribs[:value] = attribs[:value] || attribs[:givenname]
|
75
|
-
attribs[:value] = attribs[:value] || attribs[:first_name]
|
76
|
-
attribs[:value] = attribs[:value] || attribs[:firstname]
|
77
|
-
|
78
|
-
check_critical_attribute( attribs, :record_name )
|
79
|
-
check_critical_attribute( attribs, :value, :first_name )
|
80
|
-
attribs = tidy_attribs(attribs)
|
81
|
-
|
82
|
-
command = {action: 'create', scope: 'Users', attribute: 'FirstName'}
|
83
|
-
user_attrs = attribs.merge(command)
|
84
|
-
|
85
|
-
dscl( user_attrs, dir_info )
|
86
|
-
end
|
87
|
-
|
88
|
-
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$shortname_USERNAME LastName "$VALUE"
|
89
|
-
def user_set_last_name(attribs, dir_info)
|
90
|
-
attribs = user_record_name_alternatives(attribs)
|
91
|
-
|
92
|
-
attribs[:value] = attribs[:value] || attribs[:sn]
|
93
|
-
attribs[:value] = attribs[:value] || attribs[:surname]
|
94
|
-
attribs[:value] = attribs[:value] || attribs[:lastname]
|
95
|
-
attribs[:value] = attribs[:value] || attribs[:last_name]
|
96
|
-
attribs[:value] = attribs[:value] || attribs[:real_name]
|
97
|
-
attribs[:value] = attribs[:value] || attribs[:realname]
|
98
|
-
attribs[:value] = attribs[:value] || attribs[:short_name]
|
99
|
-
attribs[:value] = attribs[:value] || attribs[:shortname]
|
100
|
-
attribs[:value] = attribs[:value] || attribs[:user_name]
|
101
|
-
attribs[:value] = attribs[:value] || attribs[:username]
|
102
|
-
attribs[:value] = attribs[:value] || attribs[:uid]
|
103
|
-
|
104
|
-
check_critical_attribute( attribs, :record_name )
|
105
|
-
check_critical_attribute( attribs, :value, :last_name )
|
106
|
-
attribs = tidy_attribs(attribs)
|
107
|
-
|
108
|
-
command = {action: 'create', scope: 'Users', attribute: 'LastName'}
|
109
|
-
user_attrs = attribs.merge(command)
|
110
|
-
|
111
|
-
dscl( user_attrs, dir_info )
|
112
|
-
end
|
113
|
-
|
114
|
-
# sudo dscl . -create /Users/someuser UniqueID "1010"
|
115
|
-
def user_set_unique_id(attribs, dir_info)
|
116
|
-
attribs = user_record_name_alternatives(attribs)
|
117
|
-
check_critical_attribute( attribs, :record_name )
|
118
|
-
|
119
|
-
attribs[:value] = attribs[:value] || attribs[:uniqueid]
|
120
|
-
attribs[:value] = attribs[:value] || attribs[:unique_id]
|
121
|
-
attribs[:value] = attribs[:value] || attribs[:uid_number]
|
122
|
-
attribs[:value] = attribs[:value] || attribs[:uidnumber]
|
123
|
-
attribs[:value] = attribs[:value] || attribs[:usernumber]
|
124
|
-
attribs[:value] = attribs[:value] || attribs[:user_number]
|
125
|
-
|
126
|
-
check_critical_attribute( attribs, :value, :unique_id )
|
127
|
-
attribs = tidy_attribs(attribs)
|
128
|
-
|
129
|
-
command = {action: 'create', scope: 'Users', attribute: 'UniqueID'}
|
130
|
-
user_attrs = attribs.merge(command)
|
131
|
-
|
132
|
-
dscl( user_attrs, dir_info )
|
133
|
-
end
|
134
|
-
|
135
|
-
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/someuser NFSHomeDirectory /Users/someuser
|
136
|
-
def user_set_nfs_home_directory(attribs, dir_info)
|
137
|
-
attribs = user_record_name_alternatives(attribs)
|
138
|
-
|
139
|
-
attribs[:value] = attribs[:value] || attribs[:home_directory]
|
140
|
-
attribs[:value] = attribs[:value] || attribs[:nfs_home_directory]
|
141
|
-
attribs[:value] = attribs[:value] || '/Volumes/Macintosh HD/Users/someone'
|
142
|
-
|
143
|
-
check_critical_attribute( attribs, :record_name )
|
144
|
-
check_critical_attribute( attribs, :value, :home_directory )
|
145
|
-
attribs = tidy_attribs(attribs)
|
146
|
-
|
147
|
-
command = {action: 'create', scope: 'Users', attribute: 'NFSHomeDirectory'}
|
148
|
-
user_attrs = attribs.merge(command)
|
149
|
-
|
150
|
-
dscl( user_attrs, dir_info )
|
151
|
-
end
|
152
|
-
|
153
|
-
# sudo dscl . -create /Users/someuser UserShell /bin/bash
|
154
|
-
def user_set_shell(attribs, dir_info)
|
155
|
-
attribs = user_record_name_alternatives(attribs)
|
156
|
-
|
157
|
-
attribs[:value] = attribs[:value] || attribs[:user_shell]
|
158
|
-
attribs[:value] = attribs[:value] || attribs[:shell]
|
159
|
-
attribs[:value] = attribs[:value] || '/bin/bash'
|
160
|
-
|
161
|
-
check_critical_attribute( attribs, :record_name )
|
162
|
-
check_critical_attribute( attribs, :value, :shell )
|
163
|
-
attribs = tidy_attribs(attribs)
|
164
|
-
|
165
|
-
command = {action: 'create', scope: 'Users', attribute: 'UserShell'}
|
166
|
-
user_attrs = attribs.merge(command)
|
167
|
-
|
168
|
-
dscl( user_attrs, dir_info )
|
169
|
-
end
|
170
|
-
|
171
|
-
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$shortname_USERNAME mail "$VALUE"
|
172
|
-
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$shortname_USERNAME email "$VALUE"
|
173
|
-
# /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$shortname_USERNAME apple-user-mailattribute "$VALUE"
|
174
|
-
def user_set_first_email(attribs, dir_info)
|
175
|
-
attribs = user_record_name_alternatives(attribs)
|
176
|
-
|
177
|
-
attribs[:value] = attribs[:value] || attribs['apple-user-mailattribute']
|
178
|
-
attribs[:value] = attribs[:value] || attribs[:apple_user_mailattribute]
|
179
|
-
attribs[:value] = attribs[:value] || attribs[:email]
|
180
|
-
attribs[:value] = attribs[:value] || attribs[:mail]
|
181
|
-
|
182
|
-
check_critical_attribute( attribs, :record_name )
|
183
|
-
check_critical_attribute( attribs, :value, :email )
|
184
|
-
attribs = tidy_attribs(attribs)
|
185
|
-
|
186
|
-
answer = []
|
187
|
-
|
188
|
-
command = {action: 'create', scope: 'Users', attribute: 'MailAttribute'}
|
189
|
-
user_attrs = attribs.merge(command)
|
190
|
-
answer << dscl( user_attrs, dir_info )
|
191
|
-
|
192
|
-
command = {action: 'create', scope: 'Users', attribute: 'EMailAddress'}
|
193
|
-
user_attrs = attribs.merge(command)
|
194
|
-
answer << dscl( user_attrs, dir_info )
|
195
|
-
|
196
|
-
# command = {action: 'create', scope: 'Users', attribute: 'apple-user-mailattribute'}
|
197
|
-
# user_attrs = attribs.merge(command)
|
198
|
-
# answer << dscl( user_attrs, dir_info )
|
199
|
-
|
200
|
-
return answer
|
201
|
-
end
|
202
|
-
alias_method :user_set_email, :user_set_first_email
|
203
|
-
|
204
|
-
def user_append_email(attribs, dir_info)
|
205
|
-
attribs = user_record_name_alternatives(attribs)
|
206
|
-
|
207
|
-
attribs[:value] = attribs[:value] || attribs['apple-user-mailattribute']
|
208
|
-
attribs[:value] = attribs[:value] || attribs[:apple_user_mailattribute]
|
209
|
-
attribs[:value] = attribs[:value] || attribs[:e_mail_attribute]
|
210
|
-
attribs[:value] = attribs[:value] || attribs[:mail_attribute]
|
211
|
-
attribs[:value] = attribs[:value] || attribs[:email]
|
212
|
-
attribs[:value] = attribs[:value] || attribs[:mail]
|
213
|
-
|
214
|
-
check_critical_attribute( attribs, :record_name )
|
215
|
-
check_critical_attribute( attribs, :value, :email )
|
216
|
-
attribs = tidy_attribs(attribs)
|
217
|
-
|
218
|
-
answer = []
|
219
|
-
|
220
|
-
# command = {action: 'append', scope: 'Users', attribute: 'mail'}
|
221
|
-
# user_attrs = attribs.merge(command)
|
222
|
-
# answer << dscl( user_attrs, dir_info )
|
223
|
-
|
224
|
-
command = {action: 'append', scope: 'Users', attribute: 'email'}
|
225
|
-
user_attrs = attribs.merge(command)
|
226
|
-
answer << dscl( user_attrs, dir_info )
|
227
|
-
|
228
|
-
return answer
|
229
|
-
end
|
230
|
-
|
231
|
-
# sudo dscl . -create /Users/someuser PrimaryGroupID 80
|
232
|
-
def user_set_primary_group_id(attribs, dir_info)
|
233
|
-
attribs = user_record_name_alternatives(attribs)
|
234
|
-
|
235
|
-
attribs[:value] = attribs[:value] || attribs[:groupid]
|
236
|
-
attribs[:value] = attribs[:value] || attribs[:group_id]
|
237
|
-
attribs[:value] = attribs[:value] || attribs[:gidnumber]
|
238
|
-
attribs[:value] = attribs[:value] || attribs[:groupnumber]
|
239
|
-
attribs[:value] = attribs[:value] || attribs[:group_number]
|
240
|
-
attribs[:value] = attribs[:value] || attribs[:primarygroupid]
|
241
|
-
attribs[:value] = attribs[:value] || attribs[:primary_group_id]
|
242
|
-
|
243
|
-
check_critical_attribute( attribs, :record_name )
|
244
|
-
check_critical_attribute( attribs, :value, :group_id )
|
245
|
-
attribs = tidy_attribs(attribs)
|
246
|
-
|
247
|
-
command = {action: 'create', scope: 'Users', attribute: 'PrimaryGroupID'}
|
248
|
-
user_attrs = attribs.merge(command)
|
249
|
-
|
250
|
-
dscl( user_attrs, dir_info )
|
251
|
-
end
|
252
|
-
|
253
|
-
# /usr/bin/pwpolicy -a diradmin -p "TopSecret" -u username -setpassword "AnotherSecret"
|
254
|
-
# /usr/bin/dscl -plist -u diradmin -P #{adminpw} /LDAPv3/127.0.0.1 -passwd /Users/#{shortname} "#{passwd}"
|
255
|
-
def user_set_password(attribs, dir_info)
|
256
|
-
attribs = user_record_name_alternatives(attribs)
|
257
|
-
|
258
|
-
attribs[:value] = attribs[:value] || attribs[:password]
|
259
|
-
attribs[:value] = attribs[:value] || attribs[:passwd]
|
260
|
-
attribs[:value] = attribs[:value] || '*'
|
261
|
-
|
262
|
-
check_critical_attribute( attribs, :record_name )
|
263
|
-
check_critical_attribute( attribs, :value, :password )
|
264
|
-
attribs = tidy_attribs(attribs)
|
265
|
-
|
266
|
-
command = {action: 'passwd', scope: 'Users'}
|
267
|
-
user_attrs = attribs.merge(command)
|
268
|
-
|
269
|
-
dscl( user_attrs, dir_info )
|
270
|
-
end
|
271
|
-
# /usr/bin/dscl /LDAPv3/127.0.0.1 -auth #{shortname} "#{passwd}"
|
272
|
-
def user_password_verified?(attribs, dir_info)
|
273
|
-
attribs = user_record_name_alternatives(attribs)
|
274
|
-
|
275
|
-
attribs[:value] = attribs[:value] || attribs[:password]
|
276
|
-
attribs[:value] = attribs[:value] || attribs[:passwd]
|
277
|
-
|
278
|
-
check_critical_attribute( attribs, :record_name )
|
279
|
-
check_critical_attribute( attribs, :value, :password )
|
280
|
-
attribs = tidy_attribs(attribs)
|
281
|
-
|
282
|
-
command = {action: 'auth', scope: 'Users'}
|
283
|
-
user_attrs = attribs.merge(command)
|
284
|
-
|
285
|
-
dscl( user_attrs, dir_info )
|
286
|
-
end
|
287
|
-
alias_method :user_password_ok?, :user_password_verified?
|
288
|
-
|
289
|
-
# /usr/bin/pwpolicy -a diradmin -p A-B1g-S3cret -u $shortname_USERNAME -setpolicy "isDisabled=0"
|
290
|
-
def user_enable_login(attribs, dir_info)
|
291
|
-
attribs = user_record_name_alternatives(attribs)
|
292
|
-
|
293
|
-
check_critical_attribute( attribs, :record_name )
|
294
|
-
attribs = tidy_attribs(attribs)
|
295
|
-
|
296
|
-
command = {attribute: 'enableuser', value: nil}
|
297
|
-
params = command.merge(attribs)
|
298
|
-
pwpolicy(params, dir_info)
|
299
|
-
end
|
300
|
-
# /usr/bin/pwpolicy -a diradmin -p A-B1g-S3cret -u $shortname_USERNAME -setpolicy "isDisabled=1"
|
301
|
-
def user_disable_login(attribs, dir_info)
|
302
|
-
attribs = user_record_name_alternatives(attribs)
|
303
|
-
|
304
|
-
check_critical_attribute( attribs, :record_name )
|
305
|
-
attribs = tidy_attribs(attribs)
|
306
|
-
|
307
|
-
command = {attribute: 'disableuser', value: nil}
|
308
|
-
params = command.merge(attribs)
|
309
|
-
pwpolicy(params, dir_info)
|
310
|
-
end
|
311
|
-
|
312
|
-
def user_add_to_group(attribs, dir_info)
|
313
|
-
attribs = user_record_name_alternatives(attribs)
|
314
|
-
|
315
|
-
attribs[:value] = attribs[:group_membership]
|
316
|
-
attribs[:value] = attribs[:value] || attribs[:groupmembership]
|
317
|
-
attribs[:value] = attribs[:value] || attribs[:group_name]
|
318
|
-
attribs[:value] = attribs[:value] || attribs[:groupname]
|
319
|
-
attribs[:value] = attribs[:value] || attribs[:gid]
|
320
|
-
|
321
|
-
check_critical_attribute( attribs, :record_name, :username )
|
322
|
-
check_critical_attribute( attribs, :value, :groupname )
|
323
|
-
attribs = tidy_attribs(attribs)
|
324
|
-
command = { operation: 'edit', action: 'add', type: 'user'}
|
325
|
-
user_attrs = attribs.merge(command)
|
326
|
-
|
327
|
-
dseditgroup( user_attrs, dir_info )
|
328
|
-
end
|
329
|
-
|
330
|
-
def user_remove_from_group(attribs, dir_info)
|
331
|
-
attribs = user_record_name_alternatives(attribs)
|
332
|
-
|
333
|
-
attribs[:value] = attribs[:group_membership]
|
334
|
-
attribs[:value] = attribs[:value] || attribs[:groupmembership]
|
335
|
-
attribs[:value] = attribs[:value] || attribs[:group_name]
|
336
|
-
attribs[:value] = attribs[:value] || attribs[:groupname]
|
337
|
-
attribs[:value] = attribs[:value] || attribs[:gid]
|
338
|
-
|
339
|
-
check_critical_attribute( attribs, :record_name, :username )
|
340
|
-
check_critical_attribute( attribs, :value, :groupname )
|
341
|
-
attribs = tidy_attribs(attribs)
|
342
|
-
command = { operation: 'edit', action: 'delete', type: 'user'}
|
343
|
-
user_attrs = attribs.merge(command)
|
344
|
-
|
345
|
-
dseditgroup( user_attrs, dir_info )
|
346
|
-
end
|
347
|
-
|
348
|
-
# /usr/bin/pwpolicy -a diradmin -p A-B1g-S3cret -u $shortname_USERNAME -getpolicy
|
349
|
-
def user_get_policy(attribs, dir_info)
|
350
|
-
attribs = user_record_name_alternatives(attribs)
|
351
|
-
|
352
|
-
check_critical_attribute( attribs, :record_name )
|
353
|
-
attribs = tidy_attribs(attribs)
|
354
|
-
|
355
|
-
command = {attribute: 'getpolicy', value: nil}
|
356
|
-
params = command.merge(attribs)
|
357
|
-
pwpolicy(params, dir_info)
|
358
|
-
end
|
359
|
-
alias_method :user_login_enabled?, :user_get_policy
|
18
|
+
include OpenDirectoryUtils::CommandsGroups
|
19
|
+
include OpenDirectoryUtils::CommandsUserAttribs
|
360
20
|
|
361
21
|
# https://images.apple.com/server/docs/Command_Line.pdf
|
362
22
|
# https://serverfault.com/questions/20702/how-do-i-create-user-accounts-from-the-terminal-in-mac-os-x-10-5?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
|
@@ -415,15 +75,77 @@ module OpenDirectoryUtils
|
|
415
75
|
attribs[:value] = nil
|
416
76
|
answer << user_set_first_name(attribs, dir_info)
|
417
77
|
end
|
418
|
-
# skip email if non-sent
|
419
78
|
if attribs[:email] or attribs[:mail] or attribs[:apple_user_mailattribute]
|
420
79
|
attribs[:value] = nil
|
421
80
|
answer << user_set_email(attribs, dir_info)
|
422
81
|
end
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
82
|
+
if attribs[:relations] or attribs[:relationships]
|
83
|
+
attribs[:value] = nil
|
84
|
+
answer << user_set_relationships(attribs, dir_info)
|
85
|
+
end
|
86
|
+
if attribs[:org_info] or attribs[:organization_info]
|
87
|
+
attribs[:value] = nil
|
88
|
+
answer << user_set_organization_info(attribs, dir_info)
|
89
|
+
end
|
90
|
+
if attribs[:group_name] or attribs[:groupname] or attribs[:gid] or
|
91
|
+
attribs[:group_membership] or attribs[:groupmembership]
|
92
|
+
attribs[:value] = nil
|
93
|
+
answer << user_add_to_group(attribs, dir_info)
|
94
|
+
end
|
95
|
+
|
96
|
+
return answer.flatten
|
97
|
+
end
|
98
|
+
|
99
|
+
def user_update(attribs, dir_info)
|
100
|
+
attribs = user_record_name_alternatives(attribs)
|
101
|
+
|
102
|
+
check_critical_attribute( attribs, :record_name )
|
103
|
+
# attribs = tidy_attribs(attribs).dup
|
104
|
+
attribs = tidy_attribs(attribs)
|
105
|
+
|
106
|
+
answer = []
|
107
|
+
if attribs[:shell]
|
108
|
+
attribs[:value] = nil
|
109
|
+
answer << user_set_shell(attribs, dir_info)
|
110
|
+
end
|
111
|
+
if attribs[:last_name] or attribs[:lastname] or attribs[:surname] or attribs[:sn]
|
112
|
+
attribs[:value] = nil
|
113
|
+
answer << user_set_last_name(attribs, dir_info)
|
114
|
+
end
|
115
|
+
if attribs[:real_name] or attribs[:realname] or attribs[:fullname]
|
116
|
+
attribs[:value] = nil
|
117
|
+
answer << user_set_real_name(attribs, dir_info)
|
118
|
+
end
|
119
|
+
if attribs[:unique_id] or attribs[:uniqueid] or attribs[:uidnumber]
|
120
|
+
attribs[:value] = nil
|
121
|
+
answer << user_set_unique_id(attribs, dir_info)
|
122
|
+
end
|
123
|
+
if attribs[:primary_group_id] or attribs[:primarygroupid] or
|
124
|
+
attribs[:group_id] or attribs[:groupid] or attribs[:gidnumber]
|
125
|
+
attribs[:value] = nil
|
126
|
+
answer << user_set_primary_group_id(attribs, dir_info)
|
127
|
+
end
|
128
|
+
if attribs[:nfs_home_directory] or attribs[:home_directory]
|
129
|
+
attribs[:value] = nil
|
130
|
+
answer << user_set_nfs_home_directory(attribs, dir_info)
|
131
|
+
end
|
132
|
+
if attribs[:first_name] or attribs[:firstname] or attribs[:given_name] or
|
133
|
+
attribs[:givenname]
|
134
|
+
attribs[:value] = nil
|
135
|
+
answer << user_set_first_name(attribs, dir_info)
|
136
|
+
end
|
137
|
+
if attribs[:email] or attribs[:mail]
|
138
|
+
attribs[:value] = nil
|
139
|
+
answer << user_set_email(attribs, dir_info)
|
140
|
+
end
|
141
|
+
if attribs[:relations] or attribs[:relationships]
|
142
|
+
attribs[:value] = nil
|
143
|
+
answer << user_set_relationships(attribs, dir_info)
|
144
|
+
end
|
145
|
+
if attribs[:org_info] or attribs[:organization_info]
|
146
|
+
attribs[:value] = nil
|
147
|
+
answer << user_set_organization_info(attribs, dir_info)
|
148
|
+
end
|
427
149
|
if attribs[:group_name] or attribs[:groupname] or attribs[:gid] or
|
428
150
|
attribs[:group_membership] or attribs[:groupmembership]
|
429
151
|
attribs[:value] = nil
|
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'net/ssh'
|
2
2
|
require "open_directory_utils/version"
|
3
3
|
require "open_directory_utils/commands_base"
|
4
|
+
require "open_directory_utils/commands_groups"
|
4
5
|
require "open_directory_utils/commands_user_attribs"
|
5
|
-
# require "open_directory_utils/commands_user_attribs_ldap"
|
6
6
|
require "open_directory_utils/commands_user_create_remove"
|
7
|
-
require "open_directory_utils/commands_group_create_remove"
|
8
7
|
|
9
8
|
module OpenDirectoryUtils
|
10
9
|
class Connection
|
@@ -13,10 +12,9 @@ module OpenDirectoryUtils
|
|
13
12
|
|
14
13
|
include OpenDirectoryUtils::Version
|
15
14
|
include OpenDirectoryUtils::CommandsBase
|
15
|
+
include OpenDirectoryUtils::CommandsGroups
|
16
16
|
include OpenDirectoryUtils::CommandsUserAttribs
|
17
|
-
# include OpenDirectoryUtils::CommandsUserAttribsLdap
|
18
17
|
include OpenDirectoryUtils::CommandsUserCreateRemove
|
19
|
-
include OpenDirectoryUtils::CommandsGroupCreateRemove
|
20
18
|
|
21
19
|
# configure connection with ENV_VARS (or parameters)
|
22
20
|
# @params [Hash] - reqiured info includes: srv_hostname:, srv_username: (password: if not using ssh-keys)
|
@@ -59,6 +57,7 @@ module OpenDirectoryUtils
|
|
59
57
|
results = send_cmds_to_od_server(ssh_cmds)
|
60
58
|
# pp results
|
61
59
|
answer = process_results(results, command, params, ssh_cmds )
|
60
|
+
params[:value] = nil
|
62
61
|
return answer
|
63
62
|
rescue ArgumentError, NoMethodError => error
|
64
63
|
format_results(error.message, command, params, ssh_cmds, 'error')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_directory_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bill Tihen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-06-
|
12
|
+
date: 2018-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|
@@ -88,11 +88,13 @@ files:
|
|
88
88
|
- bin/setup
|
89
89
|
- examples/connection-sample.yml
|
90
90
|
- examples/create_od_users.rb
|
91
|
+
- examples/relations.yml
|
92
|
+
- examples/update_relationship.rb
|
91
93
|
- examples/users-sample.yml
|
92
94
|
- lib/open_directory_utils.rb
|
93
95
|
- lib/open_directory_utils/clean_check.rb
|
94
96
|
- lib/open_directory_utils/commands_base.rb
|
95
|
-
- lib/open_directory_utils/
|
97
|
+
- lib/open_directory_utils/commands_groups.rb
|
96
98
|
- lib/open_directory_utils/commands_user_attribs.rb
|
97
99
|
- lib/open_directory_utils/commands_user_create_remove.rb
|
98
100
|
- lib/open_directory_utils/connection.rb
|