Added documentation to win_shadow

Added ability to get the date the password was changed in win_useradd
This commit is contained in:
twangboy 2015-10-30 16:44:36 -06:00
parent fc8f197f69
commit 4b36cb8b6e
2 changed files with 73 additions and 15 deletions

View file

@ -24,33 +24,73 @@ def info(name):
Return information for the specified user
This is just returns dummy data so that salt states can work.
:param str name: The name of the user account to show.
CLI Example:
.. code-block:: bash
salt '*' shadow.info root
'''
ret = {
'name': name,
'passwd': '',
'lstchg': '',
'min': '',
'max': '',
'warn': '',
'inact': '',
'expire': ''}
info = __salt__['user.info'](name=name)
ret = {'name': '',
'passwd': '',
'lstchg': '',
'min': '',
'max': '',
'warn': '',
'inact': '',
'expire': ''}
if info:
ret = {'name': info['name'],
'passwd': 'Unavailable',
'lstchg': info['password_changed'],
'min': '',
'max': '',
'warn': '',
'inact': '',
'expire': info['expiration_date']}
return ret
def set_expire(name, expire):
'''
Set the expiration date for a user account.
:param name: The name of the user account to edit.
:param expire: The date the account will expire.
:return: True if successful. False if unsuccessful.
:rtype: bool
'''
return __salt__['user.update'](name, expiration_date=expire)
def force_password_change(name):
def require_password_change(name):
'''
Require the user to change their password the next time they log in.
:param name: The name of the user account to require a password change.
:return: True if successful. False if unsuccessful.
:rtype: bool
'''
return __salt__['user.update'](name, expired=True)
def unlock_account(name):
'''
Unlocks a user account.
:param name: The name of the user account to unlock.
:return: True if successful. False if unsuccessful.
:rtype: bool
'''
return __salt__['user.update'](name, unlock_account=True)
@ -58,6 +98,13 @@ def set_password(name, password):
'''
Set the password for a named user.
:param str name: The name of the user account
:param str password: The new password
:return: True if successful. False if unsuccessful.
:rtype: bool
CLI Example:
.. code-block:: bash
@ -65,7 +112,3 @@ def set_password(name, password):
salt '*' shadow.set_password root mysecretpassword
'''
return __salt__['user.update'](name=name, password=password)
def info(name):
return __salt__['user.info'](name=name)

View file

@ -741,6 +741,14 @@ def info(name):
- home
- homedrive
- groups
- password_changed
- successful_logon_attempts
- failed_logon_attempts
- last_logon
- account_disabled
- account_locked
- password_never_expires
- disallow_change_password
- gid
:rtype: dict
@ -775,6 +783,9 @@ def info(name):
ret['profile'] = items['profile']
ret['failed_logon_attempts'] = items['bad_pw_count']
ret['successful_logon_attempts'] = items['num_logons']
secs = time.mktime(datetime.now().timetuple()) - items['password_age']
ret['password_changed'] = datetime.fromtimestamp(secs). \
strftime('%Y-%m-%d %H:%M:%S')
if items['last_logon'] == 0:
ret['last_logon'] = 'Never'
else:
@ -809,7 +820,11 @@ def info(name):
ret['gid'] = ''
return ret
return ret
else:
return False
def _get_userprofile_from_registry(user, sid):