Class: Sys::User

Inherits:
Object
  • Object
show all
Defined in:
lib/windows/sys/admin.rb

Constant Summary collapse

TEMP_DUPLICATE =

An account for users whose primary account is in another domain.

0x0100
NORMAL =

Default account type that represents a typical user.

0x0200
INTERDOMAIN_TRUST =

A permit to trust account for a domain that trusts other domains.

0x0800
WORKSTATION_TRUST =

An account for a Windows NT/2000 workstation or server that is a member of this domain.

0x1000
SERVER_TRUST =

A computer account for a backup domain controller that is a member of this domain.

0x2000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ User

Creates an returns a new User object. A User object encapsulates a user account on the operating system.

Yields self if a block is provided.

Yields:

  • (_self)

Yield Parameters:

  • _self (Sys::User)

    the object that the method was called on



187
188
189
# File 'lib/windows/sys/admin.rb', line 187

def initialize
  yield self if block_given?
end

Instance Attribute Details

#account_typeObject

Returns the account type as a human readable string.



180
181
182
# File 'lib/windows/sys/admin.rb', line 180

def 
  @account_type
end

#captionObject

Domain and username of the account.



122
123
124
# File 'lib/windows/sys/admin.rb', line 122

def caption
  @caption
end

#descriptionObject

Description of the account.



125
126
127
# File 'lib/windows/sys/admin.rb', line 125

def description
  @description
end

#dirObject

The user’s home directory



159
160
161
# File 'lib/windows/sys/admin.rb', line 159

def dir
  @dir
end

#disabled=(value) ⇒ Object (writeonly)

Used to set whether or not the account is disabled.



162
163
164
# File 'lib/windows/sys/admin.rb', line 162

def disabled=(value)
  @disabled = value
end

#domainObject

Name of the Windows domain to which a user account belongs.



128
129
130
# File 'lib/windows/sys/admin.rb', line 128

def domain
  @domain
end

#full_nameObject

Full name of a local user.



134
135
136
# File 'lib/windows/sys/admin.rb', line 134

def full_name
  @full_name
end

#gidObject

The user’s primary group ID.



156
157
158
# File 'lib/windows/sys/admin.rb', line 156

def gid
  @gid
end

#groupsObject

An array of groups to which the user belongs.



137
138
139
# File 'lib/windows/sys/admin.rb', line 137

def groups
  @groups
end

#install_dateObject

Date the user account was created.



140
141
142
# File 'lib/windows/sys/admin.rb', line 140

def install_date
  @install_date
end

#local=(value) ⇒ Object (writeonly)

Sets whether or not the account is defined on the local computer.



165
166
167
# File 'lib/windows/sys/admin.rb', line 165

def local=(value)
  @local = value
end

#lockout=(value) ⇒ Object (writeonly)

Sets whether or not the account is locked out of the OS.



168
169
170
# File 'lib/windows/sys/admin.rb', line 168

def lockout=(value)
  @lockout = value
end

#nameObject

Name of the Windows user account on the domain that the User#domain property specifies.



144
145
146
# File 'lib/windows/sys/admin.rb', line 144

def name
  @name
end

#passwordObject

The user’s password.



131
132
133
# File 'lib/windows/sys/admin.rb', line 131

def password
  @password
end

#password_changeable=(value) ⇒ Object (writeonly)

Sets whether or not the password for the account can be changed.



171
172
173
# File 'lib/windows/sys/admin.rb', line 171

def password_changeable=(value)
  @password_changeable = value
end

#password_expires=(value) ⇒ Object (writeonly)

Sets whether or not the password for the account expires.



174
175
176
# File 'lib/windows/sys/admin.rb', line 174

def password_expires=(value)
  @password_expires = value
end

#password_required=(value) ⇒ Object (writeonly)

Sets whether or not a password is required for the account.



177
178
179
# File 'lib/windows/sys/admin.rb', line 177

def password_required=(value)
  @password_required = value
end

#sidObject

The user’s security identifier.



147
148
149
# File 'lib/windows/sys/admin.rb', line 147

def sid
  @sid
end

#statusObject

Current status for the user, such as “ok”, “error”, etc.



150
151
152
# File 'lib/windows/sys/admin.rb', line 150

def status
  @status
end

#uidObject

The user’s id (RID).



153
154
155
# File 'lib/windows/sys/admin.rb', line 153

def uid
  @uid
end

Instance Method Details

#disabled?Boolean

Returns whether or not the account is disabled.

Returns:

  • (Boolean)


262
263
264
# File 'lib/windows/sys/admin.rb', line 262

def disabled?
  @disabled
end

#local?Boolean

Returns whether or not the account is local.

Returns:

  • (Boolean)


268
269
270
# File 'lib/windows/sys/admin.rb', line 268

def local?
  @local
end

#lockout?Boolean

Returns whether or not the account is locked out.

Returns:

  • (Boolean)


274
275
276
# File 'lib/windows/sys/admin.rb', line 274

def lockout?
  @lockout
end

#password_changeable?Boolean

Returns whether or not the password for the account is changeable.

Returns:

  • (Boolean)


280
281
282
# File 'lib/windows/sys/admin.rb', line 280

def password_changeable?
  @password_changeable
end

#password_expires?Boolean

Returns whether or not the password for the account is changeable.

Returns:

  • (Boolean)


286
287
288
# File 'lib/windows/sys/admin.rb', line 286

def password_expires?
  @password_expires
end

#password_required?Boolean

Returns whether or not the a password is required for the account.

Returns:

  • (Boolean)


292
293
294
# File 'lib/windows/sys/admin.rb', line 292

def password_required?
  @password_required
end

#sid_typeObject

Returns the SID type as a human readable string.



218
219
220
# File 'lib/windows/sys/admin.rb', line 218

def sid_type
  @sid_type
end

#sid_type=(stype) ⇒ Object

Sets the SID (Security Identifier) type to stype, which can be one of the following constant values:

  • Admin::SidTypeUser

  • Admin::SidTypeGroup

  • Admin::SidTypeDomain

  • Admin::SidTypeAlias

  • Admin::SidTypeWellKnownGroup

  • Admin::SidTypeDeletedAccount

  • Admin::SidTypeInvalid

  • Admin::SidTypeUnknown

  • Admin::SidTypeComputer



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/windows/sys/admin.rb', line 235

def sid_type=(stype)
  case stype
    when Admin::SidTypeUser
      @sid_type = 'user'
    when Admin::SidTypeGroup
      @sid_type = 'group'
    when Admin::SidTypeDomain
      @sid_type = 'domain'
    when Admin::SidTypeAlias
      @sid_type = 'alias'
    when Admin::SidTypeWellKnownGroup
      @sid_type = 'well_known_group'
    when Admin::SidTypeDeletedAccount
      @sid_type = 'deleted_account'
    when Admin::SidTypeInvalid
      @sid_type = 'invalid'
    when Admin::SidTypeUnknown
      @sid_type = 'unknown'
    when Admin::SidTypeComputer
      @sid_type = 'computer'
    else
      @sid_type = 'unknown'
  end
end