
    g5                         S SK Jr  S SKJrJr  S SKJr  S SKJ	r	J
r
Jr   " S S\	5      r " S S\	5      r " S	 S
\	5      r " S S\	5      r " S S\	5      rg)    N)AuthenticationPolicyAuthenticationSilo)
ModelError)CommandCommandErrorOptionc                       \ rS rSrSrSr\R                  \R                  \R                  S.r
\" SSSSS	S
9/r  SS jrSrg)cmd_domain_auth_silo_list   z(List authentication silos on the domain.%prog -H <URL> [options]	sambaoptscredoptshostoptsz--jsonzOutput results in JSON format.output_formatstore_constjson)helpdestactionconstNc                 N   U R                  XU5      n [        R                  " U5      nUS:X  a-  U R                  U Vs0 s H  oR                  U_M     sn5        g U H!  n[        UR                  U R                  S9  M#     g ! [         a  n[	        U5      eS nAff = fs  snf )Nr   file)	ldb_connectr   queryr   r   
print_jsonnameprintoutf)	selfr   r   r   r   ldbsilosesilos	            D/usr/lib/python3/dist-packages/samba/netcmd/domain/auth/silo/silo.pyruncmd_domain_auth_silo_list.run-   s     xH=	"&,,S1E
 F"OO?YY_?@diidii0   	"q/!	"
 @s   B B"
BBB NNNN)__name__
__module____qualname____firstlineno____doc__synopsisoptionsSambaOptionsCredentialsOptionsHostOptionstakes_optiongroupsr   takes_optionsr'   __static_attributes__r)       r&   r
   r
      sZ    2)H ))..'' 	x>#M	IM
 ;?1r8   r
   c            	           \ rS rSrSrSr\R                  \R                  \R                  S.r
\" SSSS\S	S
9/rSS jrSrg)cmd_domain_auth_silo_view?   z*View an authentication silo on the domain.r   r   --namez/Name of authentication silo to view (required).r   storeTr   r   r   typerequiredNc                     U R                  XU5      n [        R                  " XTS9nUc  [	        SU S35      eU R                  UR                  5       5        g ! [         a  n[	        U5      eS nAff = f)NcnAuthentication silo  not found.)r   r   getr   r   r   as_dict)r!   r   r   r   r   r"   r%   r$   s           r&   r'   cmd_domain_auth_silo_view.runP   su    xH=	"%))#7D
 <!5dV;GHH 	'  	"q/!	"s   A 
A4$A//A4r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r   strr6   r'   r7   r)   r8   r&   r:   r:   ?   sT    4)H ))..'' 	xE7t	EM(r8   r:   c                   2   \ rS rSrSrSr\R                  \R                  \R                  S.r
\" SSSS\S	S
9\" SSSS\S9\" SSSS\SS9\" SSSS\SS9\" SSSS\SS9\" SSSSS 9\" S!S"S#SS 9\" S$S%S&SS 9\" S'S(S)SS 9/	r\S* 5       r       S.S, jrS-rg+)/cmd_domain_auth_silo_createa   z/Create a new authentication silo on the domain.r   r   r<   'Name of authentication silo (required).r   r=   Tr>   --description-Optional description for authentication silo.descriptionr   r   r   r?   --user-authentication-policy#User account authentication policy.user_authentication_policyUSER_POLICYr   r   r   r?   metavar--service-authentication-policy.Managed service account authentication policy.service_authentication_policySERVICE_POLICY --computer-authentication-policyComputer authentication policy.computer_authentication_policyCOMPUTER_POLICY	--protect5Protect authentication silo from accidental deletion.protect
store_truer   r   r   --unprotect7Unprotect authentication silo from accidental deletion.	unprotect--auditOnly audit silo policies.audit	--enforceEnforce silo policies.enforcec                 v     [         R                  " X5      $ ! [        [        4 a  n[	        U5      eSnAff = fzHelper function to fetch auth policy or raise CommandError.

:param ldb: Ldb connection
:param name: Either the DN or name of authentication policy
Nr   findr   
ValueErrorr   r"   r   r$   s      r&   
get_policy&cmd_domain_auth_silo_create.get_policy   7    	"',,S77J' 	"q/!	"    838Nc                    U	(       a  U
(       a  [        S5      eU(       a  U(       a  [        S5      eU R                  XU5      n [        R                  " XS9nUb  [        SU S35      e[        XES9nU(       a   U R                  X5      R                  Ul        U(       a   U R                  X5      R                  Ul        U(       a   U R                  X5      R                  Ul	        Ub  Xl
        OU(       + Ul
         UR                  U5        U	(       a  UR                  U5        [        SU 3U R                  S9  g ! [         a  n[        U5      eS nAff = f! [         a  n[        U5      eS nAff = f)	N2--protect and --unprotect cannot be used together..--audit and --enforce cannot be used together.rB   rD   z already exists.)rC   rQ   zCreated authentication silo: r   )r   r   r   rF   r   ru   dnrU   r[   r_   enforcedsaverc   r   r    r!   r   r   r   r   rQ   rU   r[   r_   rc   rh   rk   rn   r"   r%   r$   s                   r&   r'   cmd_domain_auth_silo_create.run   sZ    ySTTWOPPxH=	"%))#7D
 !5dV;KLMM "TC &@CC + )CFF . *DGG /
 #M %IDM	"IIcNS!
 	-dV4499EU  	"q/!	"L  	"q/!	"s0   E )E 
EEE
E9)E44E9r)   NNNNNNNNNNNNr+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r   rJ   r6   staticmethodru   r'   r7   r)   r8   r&   rL   rL   a   s3   9)H ))..'' 	xG7t	EC!'	= 	-90s$	& 	0D3G#'	) 	154W3(	* 	{Kl	4 	}M	6 	y/L	2 	{,l	47M@ 	" 	" ;?#''+*.+/$( $;Fr8   rL   c                   2   \ rS rSrSrSr\R                  \R                  \R                  S.r
\" SSSS\S	S
9\" SSSS\S9\" SSSS\SS9\" SSSS\SS9\" SSSS\SS9\" SSSSS 9\" S!S"S#SS 9\" S$S%S&SS 9\" S'S(S)SS 9/	r\S* 5       r       S.S, jrS-rg+)/cmd_domain_auth_silo_modify   z,Modify an authentication silo on the domain.r   r   r<   rN   r   r=   Tr>   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   c                 v     [         R                  " X5      $ ! [        [        4 a  n[	        U5      eSnAff = frp   rq   rt   s      r&   ru   &cmd_domain_auth_silo_modify.get_policy  rw   rx   Nc                    U(       a  U(       a  [        S5      eU	(       a  U
(       a  [        S5      eU R                  XU5      n [        R                  " XS9nUc  [        SU S35      eU(       a  SUl        OU(       a  SUl        Ub  X^l        US:X  a  S Ul        O'U(       a   U R                  X5      R                  Ul        US:X  a  S Ul
        O'U(       a   U R                  X5      R                  Ul
        US:X  a  S Ul        O'U(       a   U R                  X5      R                  Ul         UR                  U5        U	(       a  UR                  U5        OU
(       a  UR                  U5        [        S	U 3U R                   S
9  g ! [         a  n[        U5      eS nAff = f! [         a  n[        U5      eS nAff = f)Nr{   rz   rB   rD   rE   TF zUpdated authentication silo: r   )r   r   r   rF   r   r}   rQ   rU   ru   r|   r[   r_   r~   rc   rh   r   r    r   s                   r&   r'   cmd_domain_auth_silo_modify.run  s    WOPPySTTxH=	"%))#7D
 <!5dV;GHH  DM!DM "* &+.2D+'@CC + )B.15D.*CFF . *R/26D/+DGG /	"IIcNS!s#
 	-dV4499Ee  	"q/!	"\  	"q/!	"s6   F 2)F) F) 
F&F!!F&)
G3F>>Gr)   r   r   r)   r8   r&   r   r      s4   6)H ))..'' 	xG7t	EC!'	= 	-90s$	& 	0D3G#'	) 	154W3(	* 	{Kl	4 	}M	6 	y/L	2 	{,l	47M@ 	" 	" ;?#''+*.+/$( $CFr8   r   c            	           \ rS rSrSrSr\R                  \R                  \R                  S.r
\" SSSS\S	S
9\" SSSSS9/r  SS jrSrg)cmd_domain_auth_silo_deleteiS  z,Delete an authentication silo on the domain.r   r   r<   rN   r   r=   Tr>   z--forcez+Force delete protected authentication silo.forcerd   re   Nc                    U R                  XU5      n [        R                  " XdS9nUc  [	        SU S35      e U(       a  UR                  U5        UR                  U5        [        SU 3U R                  S9  g ! [         a  n[	        U5      eS nAff = f! [         a%  nU(       d  [	        U S35      e[	        U5      eS nAff = f)NrB   rD   rE   z6
Try --force to delete protected authentication silos.zDeleted authentication silo: r   )	r   r   rF   r   r   rh   deleter   r    )	r!   r   r   r   r   r   r"   r%   r$   s	            r&   r'   cmd_domain_auth_silo_delete.rune  s     xH=	"%))#7D
 <!5dV;GHH
	"s#KK 	-dV4499E+  	"q/!	"  	""cPQS S q/!	"s.   A< )B <
BBB
C# CCr)   )NNNNNrI   r)   r8   r&   r   r   S  sq    6)H ))..'' 	xG7t	EyLL	2M FJFr8   r   )samba.getoptgetoptr1   samba.domain.modelsr   r   samba.domain.models.exceptionsr   samba.netcmdr   r   r   r
   r:   rL   r   r   r)   r8   r&   <module>r      s`   .  H 5 6 61 1D( (DrF' rFjzF' zFz.F' .Fr8   