sys-admin 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,346 +1,346 @@
1
- = Description
2
- A unified, cross-platform replacement for the Etc module that allows you to
3
- get information about users and groups.
4
-
5
- = Synopsis
6
- require 'sys/admin'
7
- include Sys
8
-
9
- Admin.get_login # -> 'djberge'
10
- Admin.get_user('djberge') # -> Admin::User object
11
- Admin.get_group(501) # -> Admin::Group object
12
-
13
- # Iterate over all users
14
- Admin.users do |usr|
15
- p usr
16
- end
17
-
18
- # Iterate over all groups
19
- Admin.groups do |grp|
20
- p grp
21
- end
22
-
23
- = Constants
24
- == Sys::Admin
25
- VERSION
26
- The version of this library, returned as a String.
27
-
28
- == Sys::Admin::User
29
- TEMP_DUPLICATE
30
- An account for users whose primary account is in another domain.
31
-
32
- NORMAL
33
- Default account type that represents a typical user.
34
-
35
- INTERDOMAIN_TRUST
36
- A permit to trust account for a domain that trusts other domains.
37
-
38
- WORKSTATION_TRUST
39
- An account for a Windows NT/2000 workstation or server that is a member
40
- member of this domain.
41
-
42
- SERVER_TRUST
43
- A computer account for a backup domain controller that is a member of this
44
- domain.
45
-
46
- = Class Methods
47
- == Sys::Admin
48
- Admin.add_global_group(group, domain)
49
- Adds the global +group+ on +domain+.
50
-
51
- Admin.add_global_user(user, domain)
52
- Adds the global +user+ on +domain+.
53
-
54
- Admin.add_local_group(group, host=localhost)
55
- Adds the local +group+ on +host+, or the localhost if no host is specified.
56
-
57
- Admin.add_local_user(user, host=localhost)
58
- Adds the local +user+ on +host+, or the localhost if no host is specified.
59
-
60
- Admin.config_global_group(user, option, domain)
61
- Configures +group+ on +domain+ using +options+. There are too many options
62
- to list here.
63
-
64
- See http://tinyurl.com/cjkzl for a list of valid options.
65
-
66
- Admin.config_local_group(user, option, host=localhost)
67
- Configures +group+ on +host+ using +options+. There are too many options
68
- to list here.
69
-
70
- See http://tinyurl.com/cjkzl for a list of valid options.
71
-
72
- Admin.config_global_user(user, option, domain)
73
- Configures +user+ on +domain+ using +options+. There are too many options
74
- to list here.
75
-
76
- See http://tinyurl.com/3hjv9 for a list of valid options.
77
-
78
- Admin.config_local_user(user, options, host=localhost)
79
- Configures the local +user+ on +host+ using +options+. If no host is
80
- specified, the default is localhost.
81
-
82
- See http://tinyurl.com/3hjv9 for a list of valid options.
83
-
84
- Admin.delete_global_group(group, domain)
85
- Deletes the global +group+ from +domain+.
86
-
87
- Admin.delete_global_user(user, domain)
88
- Deletes the global +user+ from +domain+.
89
-
90
- Admin.delete_local_group(group, host=localhost)
91
- Deletes the local +group+ from +host+, or localhost if no host is specified.
92
-
93
- Admin.delete_local_user(user, host=localhost)
94
- Deletes the local +user+ from +host+, or localhost if no host is specified.
95
-
96
- Admin.get_group(name, host=localhost, local=true)
97
- Admin.get_group(gid, host=localhost, local=true)
98
- Returns a Group object for the given name or gid. Raises an Admin::Error
99
- if a group cannot be found for that name or GID.
100
-
101
- You may specify a host from which information is retrieved.
102
- The default is the local machine. You can retrieve either a global or
103
- local group, depending on the value of the +local+ argument.
104
-
105
- Admin.get_login
106
- Returns the user name of the current login.
107
-
108
- Admin.get_user(name, host=localhost, local=true)
109
- Admin.get_user(uid, host=localhost, local=true)
110
- Returns a User object for the given name or uid. Raises an Admin::Error if
111
- a user cannot be found for that name or user ID.
112
-
113
- You may specify a +host+ from which information is retrieved. The
114
- default is the local machine. You may also specify whether to
115
- retrieve a local or global account. The default is local.
116
-
117
- Admin.groups(host=localhost, local=true)
118
- Admin.groups(host=localhost, local=true){ |grp| ... }
119
- In block form, yields a Group object for each group on the system. In
120
- non-block form, returns an Array of Group objects.
121
-
122
- You may specify a +host+ from which information is retrieved. The default
123
- is the local machine. You can retrieve either a global or local groups,
124
- depending on the value of the +local+ argument. The default is local.
125
-
126
- Admin.users(host=localhost, local=true)
127
- Admin.users(host=localhost, local=true){ |grp| ... }
128
- In block form, yields a User object for each group on the system. In
129
- non-block form, returns an Array of User objects.
130
-
131
- You may specify a +host+ from which information is retrieved. The default
132
- is the local machine. You can retrieve either a global or local users,
133
- depending on the value of the +local+ argument. The default is local.
134
-
135
- == Sys::Admin::Group
136
- Group.new
137
- Group.new{ |grp| ... }
138
- Creates and returns a Group object, which encapsulates the information
139
- typically found within an /etc/group entry, i.e. a struct group. If a
140
- block is provided, yields the object back to the block.
141
-
142
- == Sys::Admin::User
143
- User.new
144
- User.new{ |usr| ... }
145
- Creates and returns a User object, which encapsulates the information
146
- typically found within an /etc/passwd entry, i.e. a struct passwd. If a
147
- block is provided, yields the object back to the block.
148
-
149
- = Instance Methods
150
- == Sys::Admin::Group
151
- Group#caption
152
- Short description of the group.
153
-
154
- Group#caption=
155
- Sets the caption for the group. Use only when creating a new group.
156
-
157
- Group#description
158
- Description of the group.
159
-
160
- Group#description=
161
- Sets the description of the group. Use only when creating a new group.
162
-
163
- Group#domain
164
- The name of the Windows domain to which the group account belongs.
165
-
166
- Group#domain=
167
- Sets the name of the Windows domain to which the group account belongs.
168
- Use only when creating a new group.
169
-
170
- Group#install_date
171
- The date the group was added.
172
-
173
- Group#gid
174
- The group id.
175
-
176
- Group#local?
177
- Returns whether or not the group is local (vs global).
178
-
179
- Group#local=
180
- Sets whether or not the group is local (vs global).
181
-
182
- Group#name
183
- The name of the Windows group account on the given domain.
184
-
185
- Group#name=
186
- Sets the name of the Windows group account on the given domain.
187
- Use only when creating a new group.
188
-
189
- Group#sid
190
- The security identifer for the group.
191
-
192
- Group#sid=
193
- Sets the security identifer for the group.
194
-
195
- Group#sid_type
196
- The type of security identifier as a stringified value.
197
-
198
- Group#sid_type=
199
- Sets the type of security identifier as a stringified value. Use only when
200
- creating a new group.
201
-
202
- See the +constants+ section for a list of valid sid types.
203
-
204
- Group#status
205
- Current status for the group, such as "ok", "error", etc.
206
-
207
- Group#status=
208
- Sets the status for the group.
209
-
210
- == Sys::Admin::User
211
- User#account_type
212
- Returns the account type as a human readable string.
213
-
214
- User#account_type=
215
- Sets the account type. See the +constants+ section for a list of valid
216
- values you can set this to.
217
-
218
- User#caption
219
- Domain and username of the account.
220
-
221
- User#caption=
222
- Sets the domain and username of the account.
223
-
224
- User#description
225
- Description of the account.
226
-
227
- User#description=
228
- Sets the description of the account.
229
-
230
- User#dir
231
- Returns the user's home directory.
232
-
233
- User#dir=
234
- Sets the user's home directory.
235
-
236
- User#disabled?
237
- Returns whether or not the account is disabled.
238
-
239
- User#disabled=
240
- Sets whether or not the account is disabled.
241
-
242
- User#domain
243
- Name of the Windows domain to which a user account belongs.
244
-
245
- User#domain=
246
- Sets the name of the Windows domain to which a user account belongs.
247
-
248
- User#full_name
249
- Full name of a local user.
250
-
251
- User#full_name=
252
- Sets the full name of a local user.
253
-
254
- User#gid
255
- Returns the primary group ID number.
256
-
257
- User#gid=
258
- Sets the primary group ID number.
259
-
260
- User#install_date
261
- Date the user account was created.
262
-
263
- User#local?
264
- Returns whether or not the account is defined on the local computer.
265
-
266
- User#local=
267
- Sets whether or not the account is defined on the local computer.
268
-
269
- User#lockout?
270
- Returns whether or not the account is locked out of the OS.
271
-
272
- User#lockout=
273
- Sets whether or not the account is locked out of the OS.
274
-
275
- User#name
276
- Name of the Windows user account on the domain that the User#domain
277
- property specifies.
278
-
279
- User#name=
280
- Sets the name of the Windows user account on the domain that the User#domain
281
- property specifies.
282
-
283
- User#password
284
- The user's password.
285
-
286
- User#password=
287
- Sets the user's password.
288
-
289
- User#password_changeable?
290
- Returns whether or not the password for the account can be changed.
291
-
292
- User#password_changeable=
293
- Sets whether or not the password for the account can be changed.
294
-
295
- User#password_expires?
296
- Returns whether or not the password for the account expires.
297
-
298
- User#password_expires=
299
- Sets whether or not the password for the account expires.
300
-
301
- User#password_required?
302
- Returns whether or not a password is required for the account.
303
-
304
- User#password_required=
305
- Sets whether or not a password is required for the account.
306
-
307
- User#sid
308
- The user's security identifier.
309
-
310
- User#sid=
311
- Sets the user's security identifier.
312
-
313
- User#status
314
- Current status for the user, such as "ok", "error", etc.
315
-
316
- User#uid
317
- The user's user ID. This is the RID of the SID.
318
-
319
- User#uid=
320
- Sets the user's user ID.
321
-
322
- == Notes
323
- Not all platforms support all of the User members. The only ones that are
324
- supported on all platforms are name, uid, gid, dir and shell. The rest
325
- will simply return nil if they aren't supported.
326
-
327
- == Known Bugs
328
- None that I am aware of. Please log any bugs you find on the project
329
- website at http://www.rubyforge.org/projects/sysutils.
330
-
331
- == License
332
- Artistic 2.0
333
-
334
- == Copyright
335
- Copyright 2002-2014, Daniel J. Berger
336
-
337
- All Rights Reserved. This module is free software. It may be used,
338
- redistributed and/or modified under the same terms as Ruby itself.
339
-
340
- == Warranty
341
- This library is provided "as is" and without any express or
342
- implied warranties, including, without limitation, the implied
343
- warranties of merchantability and fitness for a particular purpose.
344
-
345
- == Author
346
- Daniel J. Berger
1
+ = Description
2
+ A unified, cross-platform replacement for the Etc module that allows you to
3
+ get information about users and groups.
4
+
5
+ = Synopsis
6
+ require 'sys/admin'
7
+ include Sys
8
+
9
+ Admin.get_login # -> 'djberge'
10
+ Admin.get_user('djberge') # -> Admin::User object
11
+ Admin.get_group(501) # -> Admin::Group object
12
+
13
+ # Iterate over all users
14
+ Admin.users do |usr|
15
+ p usr
16
+ end
17
+
18
+ # Iterate over all groups
19
+ Admin.groups do |grp|
20
+ p grp
21
+ end
22
+
23
+ = Constants
24
+ == Sys::Admin
25
+ VERSION
26
+ The version of this library, returned as a String.
27
+
28
+ == Sys::Admin::User
29
+ TEMP_DUPLICATE
30
+ An account for users whose primary account is in another domain.
31
+
32
+ NORMAL
33
+ Default account type that represents a typical user.
34
+
35
+ INTERDOMAIN_TRUST
36
+ A permit to trust account for a domain that trusts other domains.
37
+
38
+ WORKSTATION_TRUST
39
+ An account for a Windows NT/2000 workstation or server that is a member
40
+ member of this domain.
41
+
42
+ SERVER_TRUST
43
+ A computer account for a backup domain controller that is a member of this
44
+ domain.
45
+
46
+ = Class Methods
47
+ == Sys::Admin
48
+ Admin.add_global_group(group, domain)
49
+ Adds the global +group+ on +domain+.
50
+
51
+ Admin.add_global_user(user, domain)
52
+ Adds the global +user+ on +domain+.
53
+
54
+ Admin.add_local_group(group, host=localhost)
55
+ Adds the local +group+ on +host+, or the localhost if no host is specified.
56
+
57
+ Admin.add_local_user(user, host=localhost)
58
+ Adds the local +user+ on +host+, or the localhost if no host is specified.
59
+
60
+ Admin.config_global_group(user, option, domain)
61
+ Configures +group+ on +domain+ using +options+. There are too many options
62
+ to list here.
63
+
64
+ See http://tinyurl.com/cjkzl for a list of valid options.
65
+
66
+ Admin.config_local_group(user, option, host=localhost)
67
+ Configures +group+ on +host+ using +options+. There are too many options
68
+ to list here.
69
+
70
+ See http://tinyurl.com/cjkzl for a list of valid options.
71
+
72
+ Admin.config_global_user(user, option, domain)
73
+ Configures +user+ on +domain+ using +options+. There are too many options
74
+ to list here.
75
+
76
+ See http://tinyurl.com/3hjv9 for a list of valid options.
77
+
78
+ Admin.config_local_user(user, options, host=localhost)
79
+ Configures the local +user+ on +host+ using +options+. If no host is
80
+ specified, the default is localhost.
81
+
82
+ See http://tinyurl.com/3hjv9 for a list of valid options.
83
+
84
+ Admin.delete_global_group(group, domain)
85
+ Deletes the global +group+ from +domain+.
86
+
87
+ Admin.delete_global_user(user, domain)
88
+ Deletes the global +user+ from +domain+.
89
+
90
+ Admin.delete_local_group(group, host=localhost)
91
+ Deletes the local +group+ from +host+, or localhost if no host is specified.
92
+
93
+ Admin.delete_local_user(user, host=localhost)
94
+ Deletes the local +user+ from +host+, or localhost if no host is specified.
95
+
96
+ Admin.get_group(name, host=localhost, local=true)
97
+ Admin.get_group(gid, host=localhost, local=true)
98
+ Returns a Group object for the given name or gid. Raises an Admin::Error
99
+ if a group cannot be found for that name or GID.
100
+
101
+ You may specify a host from which information is retrieved.
102
+ The default is the local machine. You can retrieve either a global or
103
+ local group, depending on the value of the +local+ argument.
104
+
105
+ Admin.get_login
106
+ Returns the user name of the current login.
107
+
108
+ Admin.get_user(name, host=localhost, local=true)
109
+ Admin.get_user(uid, host=localhost, local=true)
110
+ Returns a User object for the given name or uid. Raises an Admin::Error if
111
+ a user cannot be found for that name or user ID.
112
+
113
+ You may specify a +host+ from which information is retrieved. The
114
+ default is the local machine. You may also specify whether to
115
+ retrieve a local or global account. The default is local.
116
+
117
+ Admin.groups(host=localhost, local=true)
118
+ Admin.groups(host=localhost, local=true){ |grp| ... }
119
+ In block form, yields a Group object for each group on the system. In
120
+ non-block form, returns an Array of Group objects.
121
+
122
+ You may specify a +host+ from which information is retrieved. The default
123
+ is the local machine. You can retrieve either a global or local groups,
124
+ depending on the value of the +local+ argument. The default is local.
125
+
126
+ Admin.users(host=localhost, local=true)
127
+ Admin.users(host=localhost, local=true){ |grp| ... }
128
+ In block form, yields a User object for each group on the system. In
129
+ non-block form, returns an Array of User objects.
130
+
131
+ You may specify a +host+ from which information is retrieved. The default
132
+ is the local machine. You can retrieve either a global or local users,
133
+ depending on the value of the +local+ argument. The default is local.
134
+
135
+ == Sys::Admin::Group
136
+ Group.new
137
+ Group.new{ |grp| ... }
138
+ Creates and returns a Group object, which encapsulates the information
139
+ typically found within an /etc/group entry, i.e. a struct group. If a
140
+ block is provided, yields the object back to the block.
141
+
142
+ == Sys::Admin::User
143
+ User.new
144
+ User.new{ |usr| ... }
145
+ Creates and returns a User object, which encapsulates the information
146
+ typically found within an /etc/passwd entry, i.e. a struct passwd. If a
147
+ block is provided, yields the object back to the block.
148
+
149
+ = Instance Methods
150
+ == Sys::Admin::Group
151
+ Group#caption
152
+ Short description of the group.
153
+
154
+ Group#caption=
155
+ Sets the caption for the group. Use only when creating a new group.
156
+
157
+ Group#description
158
+ Description of the group.
159
+
160
+ Group#description=
161
+ Sets the description of the group. Use only when creating a new group.
162
+
163
+ Group#domain
164
+ The name of the Windows domain to which the group account belongs.
165
+
166
+ Group#domain=
167
+ Sets the name of the Windows domain to which the group account belongs.
168
+ Use only when creating a new group.
169
+
170
+ Group#install_date
171
+ The date the group was added.
172
+
173
+ Group#gid
174
+ The group id.
175
+
176
+ Group#local?
177
+ Returns whether or not the group is local (vs global).
178
+
179
+ Group#local=
180
+ Sets whether or not the group is local (vs global).
181
+
182
+ Group#name
183
+ The name of the Windows group account on the given domain.
184
+
185
+ Group#name=
186
+ Sets the name of the Windows group account on the given domain.
187
+ Use only when creating a new group.
188
+
189
+ Group#sid
190
+ The security identifer for the group.
191
+
192
+ Group#sid=
193
+ Sets the security identifer for the group.
194
+
195
+ Group#sid_type
196
+ The type of security identifier as a stringified value.
197
+
198
+ Group#sid_type=
199
+ Sets the type of security identifier as a stringified value. Use only when
200
+ creating a new group.
201
+
202
+ See the +constants+ section for a list of valid sid types.
203
+
204
+ Group#status
205
+ Current status for the group, such as "ok", "error", etc.
206
+
207
+ Group#status=
208
+ Sets the status for the group.
209
+
210
+ == Sys::Admin::User
211
+ User#account_type
212
+ Returns the account type as a human readable string.
213
+
214
+ User#account_type=
215
+ Sets the account type. See the +constants+ section for a list of valid
216
+ values you can set this to.
217
+
218
+ User#caption
219
+ Domain and username of the account.
220
+
221
+ User#caption=
222
+ Sets the domain and username of the account.
223
+
224
+ User#description
225
+ Description of the account.
226
+
227
+ User#description=
228
+ Sets the description of the account.
229
+
230
+ User#dir
231
+ Returns the user's home directory.
232
+
233
+ User#dir=
234
+ Sets the user's home directory.
235
+
236
+ User#disabled?
237
+ Returns whether or not the account is disabled.
238
+
239
+ User#disabled=
240
+ Sets whether or not the account is disabled.
241
+
242
+ User#domain
243
+ Name of the Windows domain to which a user account belongs.
244
+
245
+ User#domain=
246
+ Sets the name of the Windows domain to which a user account belongs.
247
+
248
+ User#full_name
249
+ Full name of a local user.
250
+
251
+ User#full_name=
252
+ Sets the full name of a local user.
253
+
254
+ User#gid
255
+ Returns the primary group ID number.
256
+
257
+ User#gid=
258
+ Sets the primary group ID number.
259
+
260
+ User#install_date
261
+ Date the user account was created.
262
+
263
+ User#local?
264
+ Returns whether or not the account is defined on the local computer.
265
+
266
+ User#local=
267
+ Sets whether or not the account is defined on the local computer.
268
+
269
+ User#lockout?
270
+ Returns whether or not the account is locked out of the OS.
271
+
272
+ User#lockout=
273
+ Sets whether or not the account is locked out of the OS.
274
+
275
+ User#name
276
+ Name of the Windows user account on the domain that the User#domain
277
+ property specifies.
278
+
279
+ User#name=
280
+ Sets the name of the Windows user account on the domain that the User#domain
281
+ property specifies.
282
+
283
+ User#password
284
+ The user's password.
285
+
286
+ User#password=
287
+ Sets the user's password.
288
+
289
+ User#password_changeable?
290
+ Returns whether or not the password for the account can be changed.
291
+
292
+ User#password_changeable=
293
+ Sets whether or not the password for the account can be changed.
294
+
295
+ User#password_expires?
296
+ Returns whether or not the password for the account expires.
297
+
298
+ User#password_expires=
299
+ Sets whether or not the password for the account expires.
300
+
301
+ User#password_required?
302
+ Returns whether or not a password is required for the account.
303
+
304
+ User#password_required=
305
+ Sets whether or not a password is required for the account.
306
+
307
+ User#sid
308
+ The user's security identifier.
309
+
310
+ User#sid=
311
+ Sets the user's security identifier.
312
+
313
+ User#status
314
+ Current status for the user, such as "ok", "error", etc.
315
+
316
+ User#uid
317
+ The user's user ID. This is the RID of the SID.
318
+
319
+ User#uid=
320
+ Sets the user's user ID.
321
+
322
+ == Notes
323
+ Not all platforms support all of the User members. The only ones that are
324
+ supported on all platforms are name, uid, gid, dir and shell. The rest
325
+ will simply return nil if they aren't supported.
326
+
327
+ == Known Bugs
328
+ None that I am aware of. Please log any bugs you find on the project
329
+ website at http://www.rubyforge.org/projects/sysutils.
330
+
331
+ == License
332
+ Artistic 2.0
333
+
334
+ == Copyright
335
+ Copyright 2002-2014, Daniel J. Berger
336
+
337
+ All Rights Reserved. This module is free software. It may be used,
338
+ redistributed and/or modified under the same terms as Ruby itself.
339
+
340
+ == Warranty
341
+ This library is provided "as is" and without any express or
342
+ implied warranties, including, without limitation, the implied
343
+ warranties of merchantability and fitness for a particular purpose.
344
+
345
+ == Author
346
+ Daniel J. Berger