Class: Sys::Admin::User
- Inherits:
-
Object
- Object
- Sys::Admin::User
- 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
-
#access_class ⇒ Object
The user’s access class.
-
#account_type ⇒ Object
Returns the account type as a human readable string.
-
#age ⇒ Object
Used in the past for password aging.
-
#caption ⇒ Object
Domain and username of the account.
-
#change ⇒ Object
Next date a password change will be needed.
-
#comment ⇒ Object
Another comment field.
-
#description ⇒ Object
Description of the account.
-
#dir ⇒ Object
The user’s home directory.
-
#disabled ⇒ Object
writeonly
Used to set whether or not the account is disabled.
-
#domain ⇒ Object
Name of the Windows domain to which a user account belongs.
-
#expire ⇒ Object
The account’s expiration date.
-
#fields ⇒ Object
TODO: Forgot what this is.
-
#full_name ⇒ Object
Full name of a local user.
-
#gecos ⇒ Object
A comment field.
-
#gid ⇒ Object
The user’s primary group ID.
-
#groups ⇒ Object
An array of groups to which the user belongs.
-
#install_date ⇒ Object
Date the user account was created.
-
#local ⇒ Object
writeonly
Sets whether or not the account is defined on the local computer.
-
#lockout ⇒ Object
writeonly
Sets whether or not the account is locked out of the OS.
-
#login_device ⇒ Object
The name of the terminal device the user last logged on with.
-
#login_host ⇒ Object
The host name from which the user last logged in.
-
#login_time ⇒ Object
The last time the user logged in.
-
#name ⇒ Object
Name of the Windows user account on the domain that the User#domain property specifies.
-
#passwd ⇒ Object
The user’s encrypted password.
-
#password ⇒ Object
The user’s password.
-
#password_changeable ⇒ Object
writeonly
Sets whether or not the password for the account can be changed.
-
#password_expires ⇒ Object
writeonly
Sets whether or not the password for the account expires.
-
#password_required ⇒ Object
writeonly
Sets whether or not a password is required for the account.
-
#quota ⇒ Object
The user’s alloted amount of disk space.
-
#shell ⇒ Object
The user’s login shell.
-
#sid ⇒ Object
The user’s security identifier.
-
#status ⇒ Object
Current status for the user, such as “ok”, “error”, etc.
-
#uid ⇒ Object
The user’s id (RID).
Instance Method Summary collapse
-
#disabled? ⇒ Boolean
Returns whether or not the account is disabled.
-
#initialize {|_self| ... } ⇒ User
constructor
Creates an returns a new User object.
-
#local? ⇒ Boolean
Returns whether or not the account is local.
-
#lockout? ⇒ Boolean
Returns whether or not the account is locked out.
-
#password_changeable? ⇒ Boolean
Returns whether or not the password for the account is changeable.
-
#password_expires? ⇒ Boolean
Returns whether or not the password for the account is changeable.
-
#password_required? ⇒ Boolean
Returns whether or not the a password is required for the account.
-
#sid_type ⇒ Object
Returns the SID type as a human readable string.
-
#sid_type=(stype) ⇒ Object
Sets the SID (Security Identifier) type to
stype
, which can be one of the following constant values:.
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.
94 95 96 |
# File 'lib/sys/admin/common.rb', line 94 def initialize yield self if block_given? end |
Instance Attribute Details
#access_class ⇒ Object
The user’s access class.
72 73 74 |
# File 'lib/sys/admin/common.rb', line 72 def access_class @access_class end |
#account_type ⇒ Object
Returns the account type as a human readable string.
804 805 806 |
# File 'lib/windows/sys/admin.rb', line 804 def account_type @account_type end |
#age ⇒ Object
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 |
#caption ⇒ Object
Domain and username of the account.
746 747 748 |
# File 'lib/windows/sys/admin.rb', line 746 def caption @caption end |
#change ⇒ Object
Next date a password change will be needed.
51 52 53 |
# File 'lib/sys/admin/common.rb', line 51 def change @change end |
#comment ⇒ Object
Another comment field.
75 76 77 |
# File 'lib/sys/admin/common.rb', line 75 def comment @comment end |
#description ⇒ Object
Description of the account.
749 750 751 |
# File 'lib/windows/sys/admin.rb', line 749 def description @description end |
#dir ⇒ Object
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 |
#domain ⇒ Object
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 |
#expire ⇒ Object
The account’s expiration date
66 67 68 |
# File 'lib/sys/admin/common.rb', line 66 def expire @expire end |
#fields ⇒ Object
TODO: Forgot what this is.
69 70 71 |
# File 'lib/sys/admin/common.rb', line 69 def fields @fields end |
#full_name ⇒ Object
Full name of a local user.
758 759 760 |
# File 'lib/windows/sys/admin.rb', line 758 def full_name @full_name end |
#gecos ⇒ Object
A comment field. Rarely used now.
54 55 56 |
# File 'lib/sys/admin/common.rb', line 54 def gecos @gecos end |
#gid ⇒ Object
The user’s primary group ID.
48 49 50 |
# File 'lib/sys/admin/common.rb', line 48 def gid @gid end |
#groups ⇒ Object
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_date ⇒ Object
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_device ⇒ Object
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 @login_device end |
#login_host ⇒ Object
The host name from which the user last logged in.
84 85 86 |
# File 'lib/sys/admin/common.rb', line 84 def login_host @login_host end |
#login_time ⇒ Object
The last time the user logged in.
81 82 83 |
# File 'lib/sys/admin/common.rb', line 81 def login_time @login_time end |
#name ⇒ Object
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 |
#passwd ⇒ Object
The user’s encrypted password. Deprecated by /etc/shadow.
42 43 44 |
# File 'lib/sys/admin/common.rb', line 42 def passwd @passwd end |
#password ⇒ Object
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 |
#quota ⇒ Object
The user’s alloted amount of disk space.
57 58 59 |
# File 'lib/sys/admin/common.rb', line 57 def quota @quota end |
#shell ⇒ Object
The user’s login shell.
63 64 65 |
# File 'lib/sys/admin/common.rb', line 63 def shell @shell end |
#sid ⇒ Object
The user’s security identifier.
771 772 773 |
# File 'lib/windows/sys/admin.rb', line 771 def sid @sid end |
#status ⇒ Object
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 |
#uid ⇒ Object
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.
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.
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.
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.
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.
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.
916 917 918 |
# File 'lib/windows/sys/admin.rb', line 916 def password_required? @password_required end |
#sid_type ⇒ Object
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 |