o
    j	                     @   sV   d dl Z d dlZd dlmZ d dlmZ d dlmZmZ dd Z	e
dkr)e	  dS dS )    N)MSLDAPClientConnection)LDAPConnectionFactory)MSADUserMSADMachinec                  C   s  dd l } | jdd}|jdddddd |jd	d
d |jddd |jdd}d|_d|_|jddd}|jddd |jddd}|jddd |jddd}| }|jdkrbt	j
t	jd nt	j
t	jd t|j}| }| }	tt| tt|	 t||	}
|jdkrt|
  d S |jdkr|
  |
 }t|jdddd%}tj|dd}|tj |
  D ]}||!tj qW d    n1 sw   Y  t|jd  dddd&}tj|dd}|t"j |
# D ]}||!t"j qW d    d S 1 sw   Y  d S |jdkrR|
  |
 \}}t|jdddd}|
$ D ]}|%|j&d!  q3W d    d S 1 sKw   Y  d S d S )"Nr   zMS LDAP library)descriptionz-vz	--verbosecountzVerbosity, can be stacked)actiondefaulthelp
connectionz Connection string in URL format.)r
   z--treez$LDAP tree to perform the searches oncommandsTcommanddumpz!Dump all user objects to TSV fileoutfilezoutput filespnzBDump all users with servicePrincipalName attribute set to TSV filedsazGrab basic info about the AD)levelw utf8)newlineencoding	)	delimiter_compz
)'argparseArgumentParseradd_argumentadd_subparsersrequireddest
add_parser
parse_argsverboseloggingbasicConfigINFODEBUGr   from_urlr   get_credential
get_targetprintstrr   r   get_server_infoconnectget_ad_infoopenr   csvwriterwriterowr   	TSV_ATTRSget_all_user_objectsget_rowr   get_all_machine_objectsget_all_service_user_objectswritesAMAccountName)r   parser
subparsers
dump_group	spn_group	dsa_groupargsurl_deccredstargetr   adinfofr2   usercomperr rI   /root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/msldap/__main__.pyrun   sf   


$$rK   __main__)r$   r1   msldap.connectionr   msldap.commons.factoryr   msldap.ldap_objectsr   r   rK   __name__rI   rI   rI   rJ   <module>   s   <
