open_directory_utils 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbeb4cb66c90f18b5383f6f5cc872187e27d259ca54bcb32eecb9fc1b36fe473
4
- data.tar.gz: c7b72cf17d3dd3b8d1e47fc22c138951efaecce65d19a47cb56f7936fd2e7a85
3
+ metadata.gz: f61e2e2aca525175359c6fb86db2fd8a29951f2b36a134dbce4eed2c58bd646a
4
+ data.tar.gz: da2402a3e3c19cc361173a28765af73b97c15ffa920c0135774cb10c966d1c99
5
5
  SHA512:
6
- metadata.gz: 11995f4d723e3c57334db8eb29838fe6867c94ca259f74628acc758e1768745a0b30cc97a47b8372aa95fa8e1cd4e19e8955dc9ad6e283b20fdd3750e14c1e75
7
- data.tar.gz: 75a8982397a6c7931d6d4c9a553864d5992ffe177576506c76069ad41cc907870d704de46121cec14eb1146293a933ef9b97e11c0e9835a0f46244cb572e2de7
6
+ metadata.gz: b2331c724ea6e615328177b1665268623da72f4944c52659b6c381ecda39899a2269db1408f8321c2315094c7c74f6b9ac6c6551ef0dc567c2b34d21f022410f
7
+ data.tar.gz: 372507f3d5f28b8984ac319cd57700bda70c51fffde75757a7b594efcb40b657a17675f433e09338625d3f64156de2e6cf8f57ad47f018e31087118b9fb3fc41
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- open_directory_utils (0.1.2)
4
+ open_directory_utils (0.1.3)
5
5
  net-ssh (~> 4.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -7,7 +7,10 @@ One can also build custom DSCL commands and send them to the server as needed to
7
7
 
8
8
  ## Change Log
9
9
 
10
- * **v0.1.2** - 2018-06-10
10
+ * **v0.1.3** - 2018-06-13 - able to sync all fields in typcial OD
11
+ - refactored results code (ssh_cmds have redacted passwords)
12
+ - finished adding pre-built od commands for users - good for syncing accounts
13
+ * **v0.1.2** - 2018-06-09 - all user creation features enabled
11
14
  - user creation will add user to a group if group_name present
12
15
  - new accounts disabled by default (w/ option to enable on creation)
13
16
  - now repo includes example code (to create accounts)
@@ -18,16 +21,11 @@ One can also build custom DSCL commands and send them to the server as needed to
18
21
 
19
22
  ## ToDo
20
23
 
21
- * ADD Lock and unlock account authentication (& TEST) - sync and create
22
24
  * Do not return dir admin password with command on errors
23
25
  * LDAP attributes (so las can sync accounts easily)
24
- * ADD EXAMPLE CODE
25
- * Verify setting Password
26
- * Verify testing Password
27
26
  * Refactor Process Results
28
- * Test dscl direct commands
27
+ * Test direct commands
29
28
  * Check Connection Unit Tests
30
- * Learn dscl OD property names from LDAP
31
29
  * verify which email address is LDAP (& seen in GUI)
32
30
 
33
31
  ## Installation
@@ -67,13 +65,15 @@ od = OpenDirectoryUtils::Connection.new(
67
65
  }
68
66
  )
69
67
 
70
- user_params = { user_name: 'someone', user_number: 9876, group_number: 4321,
68
+ user_params = { user_name: 'someone', user_number: 9876,
71
69
  first_name: 'Someone', last__name: 'Special',
70
+ group_number: 4321,group_name: 'employee'
71
+ }
72
+ group_params = {group_name: 'agroup', real_name: 'A Group',
73
+ group_number: 5432
72
74
  }
73
- group_params = {group_name: 'agroup', long_name: 'A Group', group_number: 5432}
74
-
75
75
  # create a user
76
- od.run( command: :user_create_full, params: user_params )
76
+ od.run( command: :user_create, params: user_params )
77
77
 
78
78
  # update user's record (all dscl and ldap fields are available)
79
79
  od.run( command: :user_set_first_email,
@@ -22,9 +22,12 @@ users = []
22
22
  begin
23
23
  users = YAML.load( File.open('users.yml') )
24
24
  rescue Errno::ENOENT, LoadError, Psych::SyntaxError, YAML::Error
25
- users = [{username: 'odtest', usernumber: '87654321', primary_group_id: 1031}]
25
+ users = [
26
+ {username: 'odtest1', usernumber: '87654321', primary_group_id: 1031},
27
+ {username: 'odtest2', usernumber: '87654322', primary_group_id: 1031},
28
+ ]
26
29
  ensure
27
- puts "\nUSERS:"
30
+ pp "USERS:"
28
31
  pp users
29
32
  end
30
33
 
@@ -32,7 +35,7 @@ make = false
32
35
  puts "Review the user data \nEnter 'Y' to create od accounts\n (otherwise you see a dry run)"
33
36
  answer = gets.chomp.downcase
34
37
  if answer.eql? 'y'
35
- make = true
38
+ make_accts = true
36
39
  end
37
40
 
38
41
  # create accounts
@@ -41,5 +44,5 @@ Array(users).each do |person|
41
44
  # show commands
42
45
  pp od.send(:user_create, person, od.dir_info)
43
46
  # Make Account
44
- # pp od.run(command: :user_create, params: person ) if make
47
+ pp od.run(command: :user_create, params: person ) if make_accts.eql? true
45
48
  end
@@ -10,7 +10,6 @@
10
10
  :passsword: Top-Secret
11
11
  :enable: true
12
12
  :group_membership: test
13
- # for minimal data use user_create_min instead of user_create
14
13
  # acceptable minimal attributes (password is set to * - no login) & real_name = username
15
14
  - :username: odtest
16
15
  :usernumber: 87654321
@@ -12,6 +12,8 @@ module OpenDirectoryUtils
12
12
  assert{not attrib[key].nil?}
13
13
  attrib[key] = attrib[key].to_s.strip
14
14
  assert{not attrib[key].eql? ''}
15
+ assert{not attrib[key].eql? '[]'}
16
+ assert{not attrib[key].eql? '{}'}
15
17
  assert{not attrib[key].include? ' '} if key.eql? :scope
16
18
  assert{not attrib[key].include? ' '} if [:uid, :username, :record_name].include? key
17
19
  rescue NoMethodError, ArgumentError => error
@@ -1,4 +1,4 @@
1
- require "open_directory_utils/dscl"
1
+ # require "open_directory_utils/dscl"
2
2
  require "open_directory_utils/clean_check"
3
3
  require "open_directory_utils/commands_base"
4
4
 
@@ -8,14 +8,12 @@ module OpenDirectoryUtils
8
8
  # @note - these commands were derived from the following resrouces:
9
9
  # * http://krypted.com/mac-os-x/create-groups-using-dscl/
10
10
  # * https://apple.stackexchange.com/questions/307173/creating-a-group-via-users-groups-in-command-line?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
11
- module CommandsGroup
11
+ module CommandsGroupCreateRemove
12
12
 
13
13
  # include OpenDirectoryUtils::Dscl
14
14
  include OpenDirectoryUtils::CleanCheck
15
15
  include OpenDirectoryUtils::CommandsBase
16
16
 
17
- require "open_directory_utils/commands_group"
18
-
19
17
  # dscl . read /Groups/ladmins
20
18
  def group_get_info(attribs, dir_info)
21
19
  attribs = group_record_name_alternatives(attribs)
@@ -60,25 +58,25 @@ module OpenDirectoryUtils
60
58
  dscl( cmd_attribs, dir_info )
61
59
  end
62
60
 
63
- def user_remove_from_group(attribs, dir_info)
64
- attribs = user_record_name_alternatives(attribs)
65
-
66
- attribs[:value] = attribs[:group_membership]
67
- attribs[:value] = attribs[:value] || attribs[:groupmembership]
68
- attribs[:value] = attribs[:value] || attribs[:group_name]
69
- attribs[:value] = attribs[:value] || attribs[:groupname]
70
- attribs[:value] = attribs[:value] || attribs[:gid]
71
-
72
- check_critical_attribute( attribs, :record_name, :username )
73
- check_critical_attribute( attribs, :value, :groupname )
74
- attribs = tidy_attribs(attribs)
75
- command = { operation: 'edit', action: 'delete', type: 'user'}
76
- user_attrs = attribs.merge(command)
77
-
78
- dseditgroup( user_attrs, dir_info )
79
- end
80
- # module_function :user_remove_from_group
81
- # alias_method :user_remove_group_memebership, :user_remove_from_group
61
+ # def user_remove_from_group(attribs, dir_info)
62
+ # attribs = user_record_name_alternatives(attribs)
63
+ #
64
+ # attribs[:value] = attribs[:group_membership]
65
+ # attribs[:value] = attribs[:value] || attribs[:groupmembership]
66
+ # attribs[:value] = attribs[:value] || attribs[:group_name]
67
+ # attribs[:value] = attribs[:value] || attribs[:groupname]
68
+ # attribs[:value] = attribs[:value] || attribs[:gid]
69
+ #
70
+ # check_critical_attribute( attribs, :record_name, :username )
71
+ # check_critical_attribute( attribs, :value, :groupname )
72
+ # attribs = tidy_attribs(attribs)
73
+ # command = { operation: 'edit', action: 'delete', type: 'user'}
74
+ # user_attrs = attribs.merge(command)
75
+ #
76
+ # dseditgroup( user_attrs, dir_info )
77
+ # end
78
+ # # module_function :user_remove_from_group
79
+ # # alias_method :user_remove_group_memebership, :user_remove_from_group
82
80
 
83
81
  # dscl . -delete /Groups/yourGroupName
84
82
  # https://tutorialforlinux.com/2011/09/15/delete-users-and-groups-from-terminal/
@@ -0,0 +1,441 @@
1
+ # require "open_directory_utils/dscl"
2
+ require "open_directory_utils/clean_check"
3
+ require "open_directory_utils/commands_base"
4
+
5
+ module OpenDirectoryUtils
6
+
7
+ # this is a long list of pre-built dscl commands affecting users to accomplish common actions
8
+ # @note - these commands were derived from the following resrouces:
9
+ # * https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/dscl.1.html
10
+ # * https://superuser.com/questions/592921/mac-osx-users-vs-dscl-command-to-list-user/621055?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
11
+ module CommandsUserAttribs
12
+
13
+ # include OpenDirectoryUtils::Dscl
14
+ include OpenDirectoryUtils::CleanCheck
15
+ include OpenDirectoryUtils::CommandsBase
16
+
17
+ def user_set_city(attribs, dir_info)
18
+ attribs = user_record_name_alternatives(attribs)
19
+ check_critical_attribute( attribs, :record_name )
20
+
21
+ attribs[:value] = attribs[:value] || attribs[:locale]
22
+ attribs[:value] = attribs[:value] || attribs[:city]
23
+ attribs[:value] = attribs[:value] || attribs[:town]
24
+ attribs[:value] = attribs[:value] || attribs[:l]
25
+
26
+ check_critical_attribute( attribs, :value, :city )
27
+ attribs = tidy_attribs(attribs)
28
+
29
+ command = {action: 'create', scope: 'Users', attribute: 'City'}
30
+ user_attrs = attribs.merge(command)
31
+
32
+ dscl( user_attrs, dir_info )
33
+ end
34
+
35
+ # first - /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$USER apple-imhandle "$VALUE"
36
+ # /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$USER apple-imhandle "AIM:created: $CREATE"
37
+ def user_create_chat(attribs, dir_info)
38
+ attribs = user_record_name_alternatives(attribs)
39
+ check_critical_attribute( attribs, :record_name )
40
+
41
+ attribs[:value] = attribs[:value] || attribs[:im_handle]
42
+ attribs[:value] = attribs[:value] || attribs[:imhandle]
43
+ attribs[:value] = attribs[:value] || attribs[:handle]
44
+ attribs[:value] = attribs[:value] || attribs[:chat]
45
+ attribs[:value] = attribs[:value] || attribs[:im]
46
+
47
+ check_critical_attribute( attribs, :value, :chat )
48
+ attribs = tidy_attribs(attribs)
49
+
50
+ command = {action: 'create', scope: 'Users', attribute: 'IMHandle'}
51
+ user_attrs = attribs.merge(command)
52
+
53
+ dscl( user_attrs, dir_info )
54
+ end
55
+
56
+ # first - /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$USER apple-imhandle "$VALUE"
57
+ # /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$USER apple-imhandle "AIM:created: $CREATE"
58
+ def user_append_chat(attribs, dir_info)
59
+ attribs = user_record_name_alternatives(attribs)
60
+ check_critical_attribute( attribs, :record_name )
61
+
62
+ attribs[:value] = attribs[:value] || attribs[:im_handle]
63
+ attribs[:value] = attribs[:value] || attribs[:imhandle]
64
+ attribs[:value] = attribs[:value] || attribs[:handle]
65
+ attribs[:value] = attribs[:value] || attribs[:chat]
66
+ attribs[:value] = attribs[:value] || attribs[:im]
67
+
68
+ check_critical_attribute( attribs, :value, :chat )
69
+ attribs = tidy_attribs(attribs)
70
+
71
+ command = {action: 'append', scope: 'Users', attribute: 'IMHandle'}
72
+ user_attrs = attribs.merge(command)
73
+
74
+ dscl( user_attrs, dir_info )
75
+ end
76
+
77
+ # first - /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$USER apple-imhandle "$VALUE"
78
+ # others - /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -append /Users/$USER apple-imhandle "$VALUE"
79
+ # /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$USER apple-imhandle "AIM:created: $CREATE"
80
+ # /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -append /Users/$USER apple-imhandle "ICQ:start: $START"
81
+ # /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -append /Users/$USER apple-imhandle "MSN:end: $END"
82
+ def user_set_chat(attribs, dir_info)
83
+ attribs = user_record_name_alternatives(attribs)
84
+ check_critical_attribute( attribs, :record_name )
85
+
86
+ attribs[:values] = attribs[:values] || attribs[:im_handle]
87
+ attribs[:values] = attribs[:values] || attribs[:imhandle]
88
+ attribs[:values] = attribs[:values] || attribs[:handle]
89
+ attribs[:values] = attribs[:values] || attribs[:chat]
90
+ attribs[:values] = attribs[:values] || attribs[:im]
91
+
92
+ answer = []
93
+ Array(attribs[:values]).each_with_index do |value, index|
94
+ attribs[:value] = value
95
+ case index
96
+ when 0
97
+ answer << user_create_chat(attribs, dir_info)
98
+ else
99
+ answer << user_append_chat(attribs, dir_info)
100
+ end
101
+ end
102
+ return answer unless attribs[:values].nil? or attribs[:values].empty?
103
+ raise ArgumentError, "values: '#{attribs[:values].inspect}' invalid, value_name: :chats"
104
+ end
105
+ alias_method :user_set_im_handle, :user_set_chat
106
+ alias_method :user_set_chat_channels, :user_set_chat
107
+ # alias_method :las_created_date, :user_set_chat
108
+ # alias_method :las_start_date, :user_set_chat
109
+ # alias_method :las_end_date, :user_set_chat
110
+
111
+
112
+ def user_set_comment(attribs, dir_info)
113
+ attribs = user_record_name_alternatives(attribs)
114
+ check_critical_attribute( attribs, :record_name )
115
+
116
+ attribs[:value] = attribs[:value] || attribs[:description]
117
+ attribs[:value] = attribs[:value] || attribs[:comment]
118
+
119
+ check_critical_attribute( attribs, :value, :comment )
120
+ attribs = tidy_attribs(attribs)
121
+
122
+ command = {action: 'create', scope: 'Users', attribute: 'Comment'}
123
+ user_attrs = attribs.merge(command)
124
+
125
+ dscl( user_attrs, dir_info )
126
+ end
127
+ alias_method :user_set_description, :user_set_comment
128
+
129
+ # /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$shortname_USERNAME apple-company "$VALUE"
130
+ def user_set_company(attribs, dir_info)
131
+ attribs = user_record_name_alternatives(attribs)
132
+ check_critical_attribute( attribs, :record_name )
133
+
134
+ attribs[:value] = attribs[:value] || attribs[:company]
135
+
136
+ check_critical_attribute( attribs, :value, :company )
137
+ attribs = tidy_attribs(attribs)
138
+
139
+ command = {action: 'create', scope: 'Users', attribute: 'Company'}
140
+ user_attrs = attribs.merge(command)
141
+
142
+ dscl( user_attrs, dir_info )
143
+ end
144
+ # alias_method :las_program_info, :user_set_company
145
+
146
+ def user_set_country(attribs, dir_info)
147
+ attribs = user_record_name_alternatives(attribs)
148
+ check_critical_attribute( attribs, :record_name )
149
+
150
+ attribs[:value] = attribs[:value] || attribs[:country]
151
+ attribs[:value] = attribs[:value] || attribs[:c]
152
+
153
+ check_critical_attribute( attribs, :value, :country )
154
+ attribs = tidy_attribs(attribs)
155
+
156
+ command = {action: 'create', scope: 'Users', attribute: 'Country'}
157
+ user_attrs = attribs.merge(command)
158
+
159
+ dscl( user_attrs, dir_info )
160
+ end
161
+
162
+ def user_set_department(attribs, dir_info)
163
+ attribs = user_record_name_alternatives(attribs)
164
+ check_critical_attribute( attribs, :record_name )
165
+
166
+ attribs[:value] = attribs[:value] || attribs[:department_number]
167
+ attribs[:value] = attribs[:value] || attribs[:departmentnumber]
168
+ attribs[:value] = attribs[:value] || attribs[:dept_number]
169
+ attribs[:value] = attribs[:value] || attribs[:deptnumber]
170
+ attribs[:value] = attribs[:value] || attribs[:department]
171
+ attribs[:value] = attribs[:value] || attribs[:dept]
172
+
173
+ check_critical_attribute( attribs, :value, :department )
174
+ attribs = tidy_attribs(attribs)
175
+
176
+ command = {action: 'create', scope: 'Users', attribute: 'Department'}
177
+ user_attrs = attribs.merge(command)
178
+
179
+ dscl( user_attrs, dir_info )
180
+ end
181
+
182
+ def user_set_job_title(attribs, dir_info)
183
+ attribs = user_record_name_alternatives(attribs)
184
+ check_critical_attribute( attribs, :record_name )
185
+
186
+ attribs[:value] = attribs[:value] || attribs[:job_title]
187
+ attribs[:value] = attribs[:value] || attribs[:jobtitle]
188
+ attribs[:value] = attribs[:value] || attribs[:title]
189
+
190
+ check_critical_attribute( attribs, :value, :job_title )
191
+ attribs = tidy_attribs(attribs)
192
+
193
+ command = {action: 'create', scope: 'Users', attribute: 'JobTitle'}
194
+ user_attrs = attribs.merge(command)
195
+
196
+ dscl( user_attrs, dir_info )
197
+ end
198
+ alias_method :user_set_title, :user_set_job_title
199
+
200
+ # 1st keyword -- /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$shortname_USERNAME apple-keyword "$VALUE"
201
+ # other keywords -- /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -append /Users/$shortname_USERNAME apple-keyword "$VALUE"
202
+ def user_create_keyword(attribs, dir_info)
203
+ attribs = user_record_name_alternatives(attribs)
204
+ check_critical_attribute( attribs, :record_name )
205
+
206
+ attribs[:value] = attribs[:value] || attribs[:keywords]
207
+ attribs[:value] = attribs[:value] || attribs[:keyword]
208
+
209
+ check_critical_attribute( attribs, :value, :keyword )
210
+ attribs = tidy_attribs(attribs)
211
+
212
+ command = {action: 'create', scope: 'Users', attribute: 'Keywords'}
213
+ user_attrs = attribs.merge(command)
214
+
215
+ dscl( user_attrs, dir_info )
216
+ end
217
+ alias_method :user_create_keywords, :user_create_keyword
218
+
219
+ # /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -append /Users/$shortname_USERNAME apple-keyword "$VALUE"
220
+ def user_append_keyword(attribs, dir_info)
221
+ attribs = user_record_name_alternatives(attribs)
222
+ check_critical_attribute( attribs, :record_name )
223
+
224
+ attribs[:value] = attribs[:value] || attribs[:keywords]
225
+ attribs[:value] = attribs[:value] || attribs[:keyword]
226
+
227
+ check_critical_attribute( attribs, :value, :keyword )
228
+ attribs = tidy_attribs(attribs)
229
+
230
+ command = {action: 'append', scope: 'Users', attribute: 'Keywords'}
231
+ user_attrs = attribs.merge(command)
232
+
233
+ dscl( user_attrs, dir_info )
234
+ end
235
+ alias_method :user_append_keywords, :user_append_keyword
236
+
237
+ # /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -append /Users/$shortname_USERNAME apple-keyword "$VALUE"
238
+ def user_set_keywords(attribs, dir_info)
239
+ attribs = user_record_name_alternatives(attribs)
240
+ check_critical_attribute( attribs, :record_name )
241
+
242
+ attribs[:values] = attribs[:values] || attribs[:keywords]
243
+ attribs[:values] = attribs[:values] || attribs[:keyword]
244
+
245
+ answer = []
246
+ Array(attribs[:values]).each_with_index do |value, index|
247
+ attribs[:value] = value
248
+
249
+ case index
250
+ when 0
251
+ answer << user_create_keyword(attribs, dir_info)
252
+ else
253
+ answer << user_append_keyword(attribs, dir_info)
254
+ end
255
+ end
256
+ return answer unless attribs[:values].nil? or attribs[:values].empty?
257
+ raise ArgumentError, "values: '#{attribs[:values].inspect}' invalid, value_name: :keywords"
258
+ end
259
+ alias_method :user_set_keyword, :user_set_keywords
260
+
261
+ # /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -append /Users/$shortname_USERNAME apple-keyword "$VALUE"
262
+ def user_set_home_phone(attribs, dir_info)
263
+ attribs = user_record_name_alternatives(attribs)
264
+ check_critical_attribute( attribs, :record_name )
265
+
266
+ attribs[:value] = attribs[:value] || attribs[:home_phone_number]
267
+ attribs[:value] = attribs[:value] || attribs[:home_number]
268
+ attribs[:value] = attribs[:value] || attribs[:home_phone]
269
+
270
+ check_critical_attribute( attribs, :value, :home_phone )
271
+ attribs = tidy_attribs(attribs)
272
+
273
+ command = {action: 'create', scope: 'Users', attribute: 'HomePhoneNumber'}
274
+ user_attrs = attribs.merge(command)
275
+
276
+ dscl( user_attrs, dir_info )
277
+ end
278
+
279
+ # /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -append /Users/$shortname_USERNAME apple-keyword "$VALUE"
280
+ def user_set_mobile_phone(attribs, dir_info)
281
+ attribs = user_record_name_alternatives(attribs)
282
+ check_critical_attribute( attribs, :record_name )
283
+
284
+ attribs[:value] = attribs[:value] || attribs[:mobile_phone_number]
285
+ attribs[:value] = attribs[:value] || attribs[:mobile_number]
286
+ attribs[:value] = attribs[:value] || attribs[:mobile_phone]
287
+
288
+ check_critical_attribute( attribs, :value, :mobile_phone )
289
+ attribs = tidy_attribs(attribs)
290
+
291
+ command = {action: 'create', scope: 'Users', attribute: 'MobileNumber'}
292
+ user_attrs = attribs.merge(command)
293
+
294
+ dscl( user_attrs, dir_info )
295
+ end
296
+ alias_method :user_set_mobile_number, :user_set_mobile_phone
297
+ alias_method :user_set_mobile_phone_number, :user_set_mobile_phone
298
+
299
+ # /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -append /Users/$shortname_USERNAME apple-keyword "$VALUE"
300
+ def user_set_work_phone(attribs, dir_info)
301
+ attribs = user_record_name_alternatives(attribs)
302
+ check_critical_attribute( attribs, :record_name )
303
+
304
+ attribs[:value] = attribs[:value] || attribs[:work_phone_number]
305
+ attribs[:value] = attribs[:value] || attribs[:phone_number]
306
+ attribs[:value] = attribs[:value] || attribs[:work_number]
307
+ attribs[:value] = attribs[:value] || attribs[:work_phone]
308
+ attribs[:value] = attribs[:value] || attribs[:number]
309
+ attribs[:value] = attribs[:value] || attribs[:phone]
310
+
311
+ check_critical_attribute( attribs, :value, :work_phone )
312
+ attribs = tidy_attribs(attribs)
313
+
314
+ command = {action: 'create', scope: 'Users', attribute: 'PhoneNumber'}
315
+ user_attrs = attribs.merge(command)
316
+
317
+ dscl( user_attrs, dir_info )
318
+ end
319
+
320
+ # /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -append /Users/$shortname_USERNAME apple-keyword "$VALUE"
321
+ def user_set_name_suffix(attribs, dir_info)
322
+ attribs = user_record_name_alternatives(attribs)
323
+ check_critical_attribute( attribs, :record_name )
324
+
325
+ attribs[:value] = attribs[:value] || attribs[:name_suffix]
326
+ attribs[:value] = attribs[:value] || attribs[:suffix]
327
+ check_critical_attribute( attribs, :value, :name_suffix )
328
+ attribs = tidy_attribs(attribs)
329
+
330
+ command = {action: 'create', scope: 'Users', attribute: 'NameSuffix'}
331
+ user_attrs = attribs.merge(command)
332
+
333
+ dscl( user_attrs, dir_info )
334
+ end
335
+
336
+ def user_set_organization_info(attribs, dir_info)
337
+ attribs = user_record_name_alternatives(attribs)
338
+ check_critical_attribute( attribs, :record_name )
339
+
340
+ attribs[:value] = attribs[:value] || attribs[:organization_info]
341
+ attribs[:value] = attribs[:value] || attribs[:organization]
342
+ attribs[:value] = attribs[:value] || attribs[:org_info]
343
+ attribs[:value] = attribs[:value] || attribs[:org]
344
+ check_critical_attribute( attribs, :value, :organization_info )
345
+ attribs = tidy_attribs(attribs)
346
+
347
+ command = {action: 'create', scope: 'Users', attribute: 'OrganizationInfo'}
348
+ user_attrs = attribs.merge(command)
349
+
350
+ dscl( user_attrs, dir_info )
351
+ end
352
+ alias_method :user_set_org_info, :user_set_organization_info
353
+ # alias_method :user_set_student_id, :user_set_organization_info
354
+
355
+ # /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$shortname_USERNAME apple-webloguri "$VALUE"
356
+ def user_set_postal_code(attribs, dir_info)
357
+ attribs = user_record_name_alternatives(attribs)
358
+ check_critical_attribute( attribs, :record_name )
359
+
360
+ attribs[:value] = attribs[:value] || attribs[:postal_code]
361
+ attribs[:value] = attribs[:value] || attribs[:post_code]
362
+ attribs[:value] = attribs[:value] || attribs[:zip_code]
363
+ attribs[:value] = attribs[:value] || attribs[:zip]
364
+ check_critical_attribute( attribs, :value, :postal_code )
365
+ attribs = tidy_attribs(attribs)
366
+
367
+ command = {action: 'create', scope: 'Users', attribute: 'PostalCode'}
368
+ user_attrs = attribs.merge(command)
369
+
370
+ dscl( user_attrs, dir_info )
371
+ end
372
+ alias_method :user_set_post_code, :user_set_postal_code
373
+ alias_method :user_set_zip_code, :user_set_postal_code
374
+ # alias_method :las_sync_date, :user_set_weblog
375
+
376
+ def user_set_relationships(attribs, dir_info)
377
+ attribs = user_record_name_alternatives(attribs)
378
+ check_critical_attribute( attribs, :record_name )
379
+
380
+ attribs[:value] = attribs[:value] || attribs[:relationships]
381
+ attribs[:value] = attribs[:value] || attribs[:relations]
382
+ check_critical_attribute( attribs, :value, :relationships )
383
+ attribs = tidy_attribs(attribs)
384
+
385
+ command = {action: 'create', scope: 'Users', attribute: 'Relationships'}
386
+ user_attrs = attribs.merge(command)
387
+
388
+ dscl( user_attrs, dir_info )
389
+ end
390
+
391
+ def user_set_state(attribs, dir_info)
392
+ attribs = user_record_name_alternatives(attribs)
393
+ check_critical_attribute( attribs, :record_name )
394
+
395
+ attribs[:value] = attribs[:value] || attribs[:state]
396
+ attribs[:value] = attribs[:value] || attribs[:st]
397
+ check_critical_attribute( attribs, :value, :state )
398
+ attribs = tidy_attribs(attribs)
399
+
400
+ command = {action: 'create', scope: 'Users', attribute: 'State'}
401
+ user_attrs = attribs.merge(command)
402
+
403
+ dscl( user_attrs, dir_info )
404
+ end
405
+
406
+ def user_set_street(attribs, dir_info)
407
+ attribs = user_record_name_alternatives(attribs)
408
+ check_critical_attribute( attribs, :record_name )
409
+
410
+ attribs[:value] = attribs[:value] || attribs[:address]
411
+ attribs[:value] = attribs[:value] || attribs[:street]
412
+ check_critical_attribute( attribs, :value, :street )
413
+ attribs = tidy_attribs(attribs)
414
+
415
+ command = {action: 'create', scope: 'Users', attribute: 'Street'}
416
+ user_attrs = attribs.merge(command)
417
+
418
+ dscl( user_attrs, dir_info )
419
+ end
420
+ alias_method :user_set_address, :user_set_street
421
+
422
+ # /usr/bin/dscl -u diradmin -P A-B1g-S3cret /LDAPv3/127.0.0.1 -create /Users/$shortname_USERNAME apple-webloguri "$VALUE"
423
+ def user_set_weblog(attribs, dir_info)
424
+ attribs = user_record_name_alternatives(attribs)
425
+ check_critical_attribute( attribs, :record_name )
426
+
427
+ attribs[:value] = attribs[:value] || attribs[:weblog]
428
+ attribs[:value] = attribs[:value] || attribs[:blog]
429
+ check_critical_attribute( attribs, :value, :weblog )
430
+ attribs = tidy_attribs(attribs)
431
+
432
+ command = {action: 'create', scope: 'Users', attribute: 'WeblogURI'}
433
+ user_attrs = attribs.merge(command)
434
+
435
+ dscl( user_attrs, dir_info )
436
+ end
437
+ alias_method :user_set_blog, :user_set_weblog
438
+ # alias_method :las_sync_date, :user_set_weblog
439
+
440
+ end
441
+ end