class Sys::Admin::User

The User class encapsulates the information found in /etc/passwd.

Constants

INTERDOMAIN_TRUST

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

NORMAL

Default account type that represents a typical user.

SERVER_TRUST

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

TEMP_DUPLICATE

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

WORKSTATION_TRUST

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

Attributes

access_class[RW]

The user's access class.

account_type[R]

Returns the account type as a human readable string.

age[RW]

Used in the past for password aging. Deprecated by /etc/shadow.

caption[RW]

Domain and username of the account.

change[RW]

Next date a password change will be needed.

comment[RW]

Another comment field.

description[RW]

Description of the account.

dir[RW]

The absolute path name of the user's home directory.

disabled[W]

Used to set whether or not the account is disabled.

domain[RW]

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

expire[RW]

The account's expiration date

fields[RW]

TODO: Forgot what this is.

full_name[RW]

Full name of a local user.

gecos[RW]

A comment field. Rarely used now.

gid[RW]

The user's group ID.

groups[RW]

An array of groups to which the user belongs.

install_date[RW]

Date the user account was created.

local[W]

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

lockout[W]

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

login_device[RW]

The name of the terminal device the user last logged on with.

login_host[RW]

The host name from which the user last logged in.

login_time[RW]

The last time the user logged in.

name[RW]

The user name associated with the account.

passwd[RW]

The user's encrypted password. Deprecated by /etc/shadow.

password[RW]

The user's password.

password_changeable[W]

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

password_expires[W]

Sets whether or not the password for the account expires.

password_required[W]

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

quota[RW]

The user's alloted amount of disk space.

shell[RW]

The user's login shell.

sid[RW]

The user's security identifier.

status[RW]

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

uid[RW]

The user's user ID.

Public Class Methods

new() { |self| ... } click to toggle source

Creates and returns a User object, which encapsulates the information typically found within an /etc/passwd entry, i.e. a struct passwd.

If a block is provided, yields the object back to the block.

# File lib/sys/admin/common.rb, line 94
def initialize
  yield self if block_given?
end

Public Instance Methods

account_type=(type) click to toggle source

Sets the account type for the account. Possible values are:

  • User::TEMP_DUPLICATE

  • User::NORMAL

  • User::INTERDOMAIN_TRUST

  • User::WORKSTATION_TRUST

  • User::SERVER_TRUST

# File lib/windows/sys/admin.rb, line 823
def account_type=(type)
  case type
    when TEMP_DUPLICATE
      @account_type = 'duplicate'
    when NORMAL
      @account_type = 'normal'
    when INTERDOMAIN_TRUST
      @account_type = 'interdomain_trust'
    when WORKSTATION_TRUST
      @account_type = 'workstation_trust'
    when SERVER_TRUST
      @account_type = 'server_trust'
    else
      @account_type = 'unknown'
  end
end
disabled?() click to toggle source

Returns whether or not the account is disabled.

# File lib/windows/sys/admin.rb, line 886
def disabled?
  @disabled
end
groups() click to toggle source

An array of groups to which the user belongs.

# File lib/sys/admin/common.rb, line 99
def groups
  array = []

  Sys::Admin.groups.each{ |grp|
    array << grp.name if grp.members.include?(self.name)
  }

  array
end
local?() click to toggle source

Returns whether or not the account is local.

# File lib/windows/sys/admin.rb, line 892
def local?
  @local
end
lockout?() click to toggle source

Returns whether or not the account is locked out.

# File lib/windows/sys/admin.rb, line 898
def lockout?
  @lockout
end
password_changeable?() click to toggle source

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

# File lib/windows/sys/admin.rb, line 904
def password_changeable?
  @password_changeable
end
password_expires?() click to toggle source

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

# File lib/windows/sys/admin.rb, line 910
def password_expires?
  @password_expires
end
password_required?() click to toggle source

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

# File lib/windows/sys/admin.rb, line 916
def password_required?
  @password_required
end
sid_type() click to toggle source

Returns the SID type as a human readable string.

# File lib/windows/sys/admin.rb, line 842
def sid_type
  @sid_type
end
sid_type=(stype) click to toggle source

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

# File lib/windows/sys/admin.rb, line 859
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