File: //lib/python3/dist-packages/samba/netcmd/__pycache__/group.cpython-310.pyc
o
�/aϼ � @ s� d dl mZ d dlmZmZmZmZ d dlZd dl m
Z
d dlmZ d dl
mZ d dlmZ d dlmZmZmZmZmZmZmZmZmZ d dlmZ d d lmZmZ d d
l m!Z! d dl"Z"d dl#Z#ddl$m%Z% e&eeeed
��Z'e&eeed��Z(G dd� de�Z)G dd� de�Z*G dd� de�Z+G dd� de�Z,G dd� de�Z-G dd� de�Z.G dd� de�Z/G dd� de�Z0G dd � d e�Z1G d!d"� d"e�Z2G d#d$� d$e�Z3G d%d&� d&e�Z4G d'd(� d(e�Z5dS ))� N)�Command�SuperCommand�CommandError�Option)�
ndr_unpack)�security)�system_session)�SamDB) �ATYPE_SECURITY_GLOBAL_GROUP�"GTYPE_SECURITY_BUILTIN_LOCAL_GROUP�!GTYPE_SECURITY_DOMAIN_LOCAL_GROUP�GTYPE_SECURITY_GLOBAL_GROUP�GTYPE_SECURITY_UNIVERSAL_GROUP�%GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP�GTYPE_DISTRIBUTION_GLOBAL_GROUP�"GTYPE_DISTRIBUTION_UNIVERSAL_GROUP�UF_ACCOUNTDISABLE)�defaultdict)�
check_call�CalledProcessError)� get_bytes� )�common)�Builtin�Domain�Global� Universal�r r r c
@ s� e Zd ZdZdZejejejd�Z e
dddeddd �e
d
ded�e
d
dg d�dd�e
ddddgdd�e
dded�e
dded�e
dded�e
dded�e
dded�g Z
d gZ ! ! !d$d"d#�Zd!S )%�
cmd_group_adda Creates a new AD group.
This command adds a new Active Directory group. The groupname specified on the command is a unique sAMAccountName.
An Active Directory group may contain user and computer accounts as well as other groups. An administrator adds a new group and adds members to that group so they can be managed as a single entity. This helps to simplify security and system administration.
Groups may also be used to establish email distribution lists, using --group-type=Distribution.
Groups are located in domains in organizational units (OUs). The group's scope is a characteristic of the group that designates the extent to which the group is applied within the domain tree or forest.
The group location (OU), type (security or distribution) and scope may all be specified on the samba-tool command when the group is created.
The command may be run from the root userid or another authorized userid. The
-H or --URL= option can be used to execute the command on a remote server.
Example1:
samba-tool group add Group1 -H ldap://samba.samdom.example.com --description='Simple group'
Example1 adds a new group with the name Group1 added to the Users container on a remote LDAP server. The -U parameter is used to pass the userid and password of a user that exists on the remote server and is authorized to issue the command on that server. It defaults to the security type and global scope.
Example2:
sudo samba-tool group add Group2 --group-type=Distribution
Example2 adds a new distribution group to the local server. The command is run under root using the sudo command.
Example3:
samba-tool group add Group3 --nis-domain=samdom --gid-number=12345
Example3 adds a new RFC2307 enabled group for NIS domain samdom and GID 12345 (both options are required to enable this feature).
�%prog <groupname> [options]�� sambaopts�versionopts�credopts�-H�--URL�%LDB URL for database or target server�URL�H��help�type�metavar�destz --groupouzpAlternative location (without domainDN counterpart) to default CN=Users in which new user object will be created�r* r+ z
--group-scope�choicer z)Group scope (Domain | Global | Universal))r+ �choicesr* z--group-type�Security�Distributionz$Group type (Security | Distribution)z
--descriptionzGroup's description�--mail-addresszGroup's email addressz--noteszGroups's notesz--gid-numberzGroup's Unix/RFC2307 GID numberz--nis-domainzSFU30 NIS Domain� groupnameNc
C s� |pddkr
t �|t�}nt�|t�}|d u r|
d us#|d ur'|
d u r'td��|�� }|j|dd�}zt|t � ||d�}|j
|||| |
|||
d� W n ty] } ztd| |��d }~ww | j�
d| � d S ) Nr1 zcBoth --gid-number and --nis-domain have to be set for a RFC2307-enabled group. Operation cancelled.T��fallback_machine��url�session_info�credentials�lp)�groupou� grouptype�description�mailaddress�notes� gidnumber� nisdomainzFailed to add group "%s"zAdded group %s
)�security_group�getr
�distribution_groupr r �get_loadparm�get_credentialsr r �newgroup� Exception�outf�write)�selfr4 r# r! r"