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
The user's access class.
Returns the account type as a human readable string.
Used in the past for password aging. Deprecated by /etc/shadow.
Domain and username of the account.
Next date a password change will be needed.
Another comment field.
Description of the account.
The absolute path name of the user's home directory.
Used to set whether or not the account is disabled.
Name of the Windows domain to which a user account belongs.
The account's expiration date
TODO: Forgot what this is.
Full name of a local user.
A comment field. Rarely used now.
The user's group ID.
An array of groups to which the user belongs.
Date the user account was created.
Sets whether or not the account is defined on the local computer.
Sets whether or not the account is locked out of the OS.
The name of the terminal device the user last logged on with.
The host name from which the user last logged in.
The last time the user logged in.
The user name associated with the account.
The user's encrypted password. Deprecated by /etc/shadow.
The user's password.
Sets whether or not the password for the account can be changed.
Sets whether or not the password for the account expires.
Sets whether or not a password is required for the account.
The user's alloted amount of disk space.
The user's login shell.
The user's security identifier.
Current status for the user, such as “ok”, “error”, etc.
The user's user ID.
Public Class Methods
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
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
Returns whether or not the account is disabled.
# File lib/windows/sys/admin.rb, line 886 def disabled? @disabled end
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
Returns whether or not the account is local.
# File lib/windows/sys/admin.rb, line 892 def local? @local end
Returns whether or not the account is locked out.
# File lib/windows/sys/admin.rb, line 898 def lockout? @lockout end
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
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
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
Returns the SID type as a human readable string.
# File lib/windows/sys/admin.rb, line 842 def sid_type @sid_type end
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