Class: Sys::Admin::User

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

Overview

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

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:



94
95
96
# File 'lib/sys/admin/common.rb', line 94

def initialize
  yield self if block_given?
end

Instance Attribute Details

#access_classObject

The user’s access class.



72
73
74
# File 'lib/sys/admin/common.rb', line 72

def access_class
  @access_class
end

#account_typeObject

Returns the account type as a human readable string.



804
805
806
# File 'lib/windows/sys/admin.rb', line 804

def 
  @account_type
end

#ageObject

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



78
79
80
# File 'lib/sys/admin/common.rb', line 78

def age
  @age
end

#captionObject

Domain and username of the account.



746
747
748
# File 'lib/windows/sys/admin.rb', line 746

def caption
  @caption
end

#changeObject

Next date a password change will be needed.



51
52
53
# File 'lib/sys/admin/common.rb', line 51

def change
  @change
end

#commentObject

Another comment field.



75
76
77
# File 'lib/sys/admin/common.rb', line 75

def comment
  @comment
end

#descriptionObject

Description of the account.



749
750
751
# File 'lib/windows/sys/admin.rb', line 749

def description
  @description
end

#dirObject

The user’s home directory



60
61
62
# File 'lib/sys/admin/common.rb', line 60

def dir
  @dir
end

#disabled=(value) ⇒ Object (writeonly)

Used to set whether or not the account is disabled.



786
787
788
# File 'lib/windows/sys/admin.rb', line 786

def disabled=(value)
  @disabled = value
end

#domainObject

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



752
753
754
# File 'lib/windows/sys/admin.rb', line 752

def domain
  @domain
end

#expireObject

The account’s expiration date



66
67
68
# File 'lib/sys/admin/common.rb', line 66

def expire
  @expire
end

#fieldsObject

TODO: Forgot what this is.



69
70
71
# File 'lib/sys/admin/common.rb', line 69

def fields
  @fields
end

#full_nameObject

Full name of a local user.



758
759
760
# File 'lib/windows/sys/admin.rb', line 758

def full_name
  @full_name
end

#gecosObject

A comment field. Rarely used now.



54
55
56
# File 'lib/sys/admin/common.rb', line 54

def gecos
  @gecos
end

#gidObject

The user’s primary group ID.



48
49
50
# File 'lib/sys/admin/common.rb', line 48

def gid
  @gid
end

#groupsObject

An array of groups to which the user belongs.



99
100
101
102
103
104
105
106
107
# 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

#install_dateObject

Date the user account was created.



764
765
766
# File 'lib/windows/sys/admin.rb', line 764

def install_date
  @install_date
end

#local=(value) ⇒ Object (writeonly)

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



789
790
791
# File 'lib/windows/sys/admin.rb', line 789

def local=(value)
  @local = value
end

#lockout=(value) ⇒ Object (writeonly)

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



792
793
794
# File 'lib/windows/sys/admin.rb', line 792

def lockout=(value)
  @lockout = value
end

#login_deviceObject

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



87
88
89
# File 'lib/sys/admin/common.rb', line 87

def 
  @login_device
end

#login_hostObject

The host name from which the user last logged in.



84
85
86
# File 'lib/sys/admin/common.rb', line 84

def 
  @login_host
end

#login_timeObject

The last time the user logged in.



81
82
83
# File 'lib/sys/admin/common.rb', line 81

def 
  @login_time
end

#nameObject

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



39
40
41
# File 'lib/sys/admin/common.rb', line 39

def name
  @name
end

#passwdObject

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



42
43
44
# File 'lib/sys/admin/common.rb', line 42

def passwd
  @passwd
end

#passwordObject

The user’s password.



755
756
757
# File 'lib/windows/sys/admin.rb', line 755

def password
  @password
end

#password_changeable=(value) ⇒ Object (writeonly)

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



795
796
797
# File 'lib/windows/sys/admin.rb', line 795

def password_changeable=(value)
  @password_changeable = value
end

#password_expires=(value) ⇒ Object (writeonly)

Sets whether or not the password for the account expires.



798
799
800
# File 'lib/windows/sys/admin.rb', line 798

def password_expires=(value)
  @password_expires = value
end

#password_required=(value) ⇒ Object (writeonly)

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



801
802
803
# File 'lib/windows/sys/admin.rb', line 801

def password_required=(value)
  @password_required = value
end

#quotaObject

The user’s alloted amount of disk space.



57
58
59
# File 'lib/sys/admin/common.rb', line 57

def quota
  @quota
end

#shellObject

The user’s login shell.



63
64
65
# File 'lib/sys/admin/common.rb', line 63

def shell
  @shell
end

#sidObject

The user’s security identifier.



771
772
773
# File 'lib/windows/sys/admin.rb', line 771

def sid
  @sid
end

#statusObject

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



774
775
776
# File 'lib/windows/sys/admin.rb', line 774

def status
  @status
end

#uidObject

The user’s id (RID).



45
46
47
# File 'lib/sys/admin/common.rb', line 45

def uid
  @uid
end

Instance Method Details

#disabled?Boolean

Returns whether or not the account is disabled.

Returns:

  • (Boolean)


886
887
888
# File 'lib/windows/sys/admin.rb', line 886

def disabled?
  @disabled
end

#local?Boolean

Returns whether or not the account is local.

Returns:

  • (Boolean)


892
893
894
# File 'lib/windows/sys/admin.rb', line 892

def local?
  @local
end

#lockout?Boolean

Returns whether or not the account is locked out.

Returns:

  • (Boolean)


898
899
900
# File 'lib/windows/sys/admin.rb', line 898

def lockout?
  @lockout
end

#password_changeable?Boolean

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

Returns:

  • (Boolean)


904
905
906
# File 'lib/windows/sys/admin.rb', line 904

def password_changeable?
  @password_changeable
end

#password_expires?Boolean

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

Returns:

  • (Boolean)


910
911
912
# File 'lib/windows/sys/admin.rb', line 910

def password_expires?
  @password_expires
end

#password_required?Boolean

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

Returns:

  • (Boolean)


916
917
918
# File 'lib/windows/sys/admin.rb', line 916

def password_required?
  @password_required
end

#sid_typeObject

Returns the SID type as a human readable string.



842
843
844
# File 'lib/windows/sys/admin.rb', line 842

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



859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
# 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