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



189
190
191
# File 'lib/windows/sys/admin.rb', line 189

def initialize
  yield self if block_given?
end

Instance Attribute Details

#account_typeObject

Returns the account type as a human readable string.



182
183
184
# File 'lib/windows/sys/admin.rb', line 182

def 
  @account_type
end

#captionObject

Domain and username of the account.



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

def caption
  @caption
end

#descriptionObject

Description of the account.



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

def description
  @description
end

#dirObject

The user’s home directory



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

def dir
  @dir
end

#disabled=(value) ⇒ Object (writeonly)

Used to set whether or not the account is disabled.



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

def disabled=(value)
  @disabled = value
end

#domainObject

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



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

def domain
  @domain
end

#full_nameObject

Full name of a local user.



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

def full_name
  @full_name
end

#gidObject

The user’s primary group ID.



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

def gid
  @gid
end

#groupsObject

An array of groups to which the user belongs.



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

def groups
  @groups
end

#install_dateObject

Date the user account was created.



142
143
144
# File 'lib/windows/sys/admin.rb', line 142

def install_date
  @install_date
end

#local=(value) ⇒ Object (writeonly)

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



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

def local=(value)
  @local = value
end

#lockout=(value) ⇒ Object (writeonly)

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



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

def lockout=(value)
  @lockout = value
end

#nameObject

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



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

def name
  @name
end

#passwordObject

The user’s password.



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

def password
  @password
end

#password_changeable=(value) ⇒ Object (writeonly)

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



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

def password_changeable=(value)
  @password_changeable = value
end

#password_expires=(value) ⇒ Object (writeonly)

Sets whether or not the password for the account expires.



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

def password_expires=(value)
  @password_expires = value
end

#password_required=(value) ⇒ Object (writeonly)

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



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

def password_required=(value)
  @password_required = value
end

#sidObject

The user’s security identifier.



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

def sid
  @sid
end

#statusObject

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



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

def status
  @status
end

#uidObject

The user’s id (RID).



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

def uid
  @uid
end

Instance Method Details

#disabled?Boolean

Returns whether or not the account is disabled.

Returns:

  • (Boolean)


264
265
266
# File 'lib/windows/sys/admin.rb', line 264

def disabled?
  @disabled
end

#local?Boolean

Returns whether or not the account is local.

Returns:

  • (Boolean)


270
271
272
# File 'lib/windows/sys/admin.rb', line 270

def local?
  @local
end

#lockout?Boolean

Returns whether or not the account is locked out.

Returns:

  • (Boolean)


276
277
278
# File 'lib/windows/sys/admin.rb', line 276

def lockout?
  @lockout
end

#password_changeable?Boolean

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

Returns:

  • (Boolean)


282
283
284
# File 'lib/windows/sys/admin.rb', line 282

def password_changeable?
  @password_changeable
end

#password_expires?Boolean

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

Returns:

  • (Boolean)


288
289
290
# File 'lib/windows/sys/admin.rb', line 288

def password_expires?
  @password_expires
end

#password_required?Boolean

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

Returns:

  • (Boolean)


294
295
296
# File 'lib/windows/sys/admin.rb', line 294

def password_required?
  @password_required
end

#sid_typeObject

Returns the SID type as a human readable string.



220
221
222
# File 'lib/windows/sys/admin.rb', line 220

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



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

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