File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/win_groupadd.cpython-310.pyc
Back
o ;j7- � @ s� d Z ddlZddlZddlZddlZzddlZddlZddlZ dZ W n ey- dZ Y nw e�e �ZdZdd� Zdd � Zd d� Zdd � Zdd� Zdd� Zdd� Zdd� Zd dd�Zdd� Zdd� Zdd� Zd dd�ZdS )!a Manage groups on Windows .. important:: If you feel that Salt should be using this module to manage groups on a minion, and it is using a different module (or gives an error similar to *'group.info' is not available*), see :ref:`here <module-provider-override>`. � NTF�groupc C s t jj�� sdS tsdS tS )z7 Set the group module if the kernel is Windows )Fz+win_groupadd: only works on Windows systems)Fz"win_groupadd: missing dependencies)�salt�utils�platformZ is_windows�HAS_DEPENDENCIES�__virtualname__� r r �M/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/win_groupadd.py�__virtual__ s r c C sH t jj�� � tj�d�} | �dd�W d � S 1 sw Y dS )z� A helper function to get the object for the local machine Returns: object: Returns the computer object for the local machine � AdsNameSpaces� zWinNT://.,computerN�r r �winapi�Com�win32com�client�Dispatch� GetObject)�ntr r r �_get_computer_object+ s $�r c C sP t jj�� � tj�d�}|�dd| � d��W d � S 1 s!w Y dS )z� A helper function to get a specified group object Args: name (str): The name of the object Returns: object: The specified group object r r z WinNT://./z,groupNr )�namer r r r �_get_group_object7 s $�r c C sT t jj�� � tj�d�} | �dd�}dg|_|W d � S 1 s#w Y dS )z� A helper function that gets a list of group objects for all groups on the machine Returns: iter: A list of objects for all groups on the machine r r z WinNT://.r N) r r r r r r r r �Filter)r �resultsr r r �_get_all_groupsG s $�r c C s | j �dd��dd�S )z� Resolve the username from the member object returned from a group query Returns: str: The username converted to domain\username format �WinNT://r �/�\)ZADSPath�replace)�memberr r r � _get_usernameV s r c K s� t | �s<t� }z|�d| �}|�� t� d| � W dS tjy; } zt�d| t� |j d �� W Y d}~dS d}~ww t�d| � dS ) z� Add the specified group Args: name (str): The name of the group to add Returns: bool: ``True`` if successful, otherwise ``False`` CLI Example: .. code-block:: bash salt '*' group.add foo r zSuccessfully created group %szFailed to create group %s. %s� NFzThe group %s already exists.T)�infor ZCreateZSetInfo�log� pywintypes� com_error�error�win32api� FormatMessage� excepinfo�warning)r �kwargs�comp_objZ new_group�excr r r �add` s$ ����r. c K s� t | �r8t� }z|�d| � t� d| � W dS tjy7 } zt�d| t�|j d �� W Y d}~dS d}~ww t� d| � dS ) a Remove the named group Args: name (str): The name of the group to remove Returns: bool: ``True`` if successful, otherwise ``False`` CLI Example: .. code-block:: bash salt '*' group.delete foo r zSuccessfully removed group %szFailed to remove group %s. %sr! NFzThe group %s does not exist.T)r"