MCPcopy
hub / github.com/saltstack/salt / setpassword

Function setpassword

salt/modules/win_useradd.py:517–544  ·  view source on GitHub ↗

Set the user's password Args: name (str): The username for which to set the password password (str): The new password Returns: bool: ``True`` if successful, otherwise ``False``. CLI Example: .. code-block:: bash salt '*' user.setpassword js

(name, password)

Source from the content-addressed store, hash-verified

515
516
517def setpassword(name, password):
518 """
519 Set the user's password
520
521 Args:
522
523 name (str): The username for which to set the password
524
525 password (str): The new password
526
527 Returns:
528 bool: ``True`` if successful, otherwise ``False``.
529
530 CLI Example:
531
532 .. code-block:: bash
533
534 salt '*' user.setpassword jsnuffy sup3rs3cr3t
535 """
536 # update() returns the Win32 error string on failure (e.g. when the user
537 # does not exist), which is truthy and would otherwise be misreported as
538 # success by callers that check the return value as a boolean. Verify the
539 # user exists first so we can return a proper ``False`` and surface a
540 # clear log message.
541 if not info(name):
542 log.error("User '%s' does not exist", name)
543 return False
544 return update(name=name, password=password) is True
545
546
547def addgroup(name, group):

Callers

nothing calls this directly

Calls 3

infoFunction · 0.70
updateFunction · 0.70
errorMethod · 0.45

Tested by

no test coverage detected