salt.modules.win_useradd

Module for managing Windows Users

depends:
  • pywintypes
  • win32api
  • win32net
  • win32netcon
  • win32profile
  • win32security
  • win32ts

NOTE: This currently only works with local user accounts, not domain accounts

salt.modules.win_useradd.add(name, password=None, fullname=False, description=None, groups=None, home=None, homedrive=None, profile=None, logonscript=None)

Add a user to the minion.

Parameters:name -- str

User name

Parameters:password -- str

User's password in plain text.

Parameters:fullname -- str

The user's full name.

Parameters:description -- str

A brief description of the user account.

Parameters:groups -- list

A list of groups to add the user to.

Parameters:home -- str

The path to the user's home directory.

Parameters:homedrive -- str

The drive letter to assign to the home directory. Must be the Drive Letter followed by a colon. ie: U:

Parameters:profile -- str

An explicit path to a profile. Can be a UNC or a folder on the system. If left blank, windows uses it's default profile directory.

Parameters:logonscript -- str

Path to a login script to run when the user logs on.

Returns:bool

True if successful. False is unsuccessful.

CLI Example:

salt '*' user.add name password
salt.modules.win_useradd.addgroup(name, group)

Add user to a group

CLI Example:

salt '*' user.addgroup username groupname
salt.modules.win_useradd.chfullname(name, fullname)

Change the full name of the user

CLI Example:

salt '*' user.chfullname user 'First Last'
salt.modules.win_useradd.chgroups(name, groups, append=False)

Change the groups this user belongs to, add append to append the specified groups

CLI Example:

salt '*' user.chgroups foo wheel,root True
salt.modules.win_useradd.chhome(name, home, persist=False)

Change the home directory of the user, pass True for persist to move files to the new home directory if the old home directory exist.

CLI Example:

salt '*' user.chhome foo \\fileserver\home\foo True
salt.modules.win_useradd.chprofile(name, profile)

Change the profile directory of the user

CLI Example:

salt '*' user.chprofile foo \\fileserver\profiles\foo
salt.modules.win_useradd.delete(name, purge=False, force=False)

Remove a user from the minion

Parameters:name --

The name of the user to delete

Parameters:purge --

Boolean value indicating that the user profile should also be removed when the user account is deleted. If set to True the profile will be removed.

Parameters:force --

Boolean value indicating that the user account should be deleted even if the user is logged in. True will log the user out and delete user.

CLI Example:

salt '*' user.delete name
salt.modules.win_useradd.getUserSid(username)
salt.modules.win_useradd.getent(refresh=False)

Return the list of all info for all users

CLI Example:

salt '*' user.getent
salt.modules.win_useradd.info(name)

Return user information

Parameters:name -- str

Username for which to display information

Returns:dict

A dictionary containing user information - fullname - username - uid - passwd (will always return None) - comment (same as description, left here for backwards compatibility) - description - active - logonscript - profile - home - homedrive - groups - gid

CLI Example:

salt '*' user.info root
salt.modules.win_useradd.list_groups(name)

Return a list of groups the named user belongs to

CLI Example:

salt '*' user.list_groups foo
salt.modules.win_useradd.list_users()

Return a list of users on Windows

salt.modules.win_useradd.removegroup(name, group)

Remove user from a group

CLI Example:

salt '*' user.removegroup username groupname
salt.modules.win_useradd.rename(name, new_name)

Change the username for a named user

CLI Example:

salt '*' user.rename name new_name
salt.modules.win_useradd.setpassword(name, password)

Set a user's password

CLI Example:

salt '*' user.setpassword name password
salt.modules.win_useradd.update(name, password=None, fullname=None, description=None, home=None, homedrive=None, logonscript=None, profile=None)

Updates settings for the windows user. Name is the only required parameter. Settings will only be changed if the parameter is passed a value.

New in version 2015.8.0.

Parameters:name -- str

The user name to update.

Parameters:password -- str

New user password in plain text.

Parameters:fullname -- str

The user's full name.

Parameters:description -- str

A brief description of the user account.

Parameters:home -- str

The path to the user's home directory.

Parameters:homedrive -- str

The drive letter to assign to the home directory. Must be the Drive Letter followed by a colon. ie: U:

Parameters:logonscript -- str

The path to the logon script.

Parameters:profile -- str

The path to the user's profile directory.

Returns:bool

True if successful. False is unsuccessful.

CLI Example:

salt '*' user.update bob password=secret profile=C:\Users\Bob
         home=\\server\homeshare\bob homedrive=U: