
    g@                         S SK r S SKJr  S SKJr  S SKJr  S SKr\" S5      r	SS jr
S rSS jrSS	 jrS
 rS rS rS rS rg)    N)nbt)Net)CommandErrorl         c                    U n[         R                  " SU 5      nU(       a  UR                  S5      nUR                  S5      nUbD  UR                  5       nUR	                  5       UR	                  5       :w  a  [        SU SU S35      eUR	                  5       SUR                  5       4$ Sn[         R                  " SU 5      nU(       a~  UR                  S5      nUR                  S5      nUbY  UR                  5       nUR                  S	S5      S
   nUR	                  5       UR	                  5       :w  a  [        SU SU S35      eUR	                  5       UR                  5       S4$ )zget the realm or the domain and the base user
from user like:
* username
* DOMAIN\username
* username@REALM

 A SamDB object can also be passed in to check
our domain or realm against the obtained ones.
z(\w+)\\(\w+$)      zGiven domain 'z' does not match our domain 'z'! z(\w+)@(\w+).r   zGiven realm 'z' does not match our realm ')	rematchgroupdomain_netbios_namelowerr   upperdomain_dns_namesplit)	usersambaseusermdomain
our_domainrealm	our_realmour_realm_initials	            5/usr/lib/python3/dist-packages/samba/netcmd/common.py_get_user_realm_domainr      sW    H
!4(A771:?002J||~!1!1!33"^F8 <22<R$A B B  "flln55E
&A771:
?++-I )Q 7 :{{} 1 7 7 99"]5' :--6Kr$; < < NNekkmR00    c                     U R                  S5      R                  5       S-   U R                  S5      R                  5       -   $ )zdreturn the full DNS name of our own host. Used as a default
for hostname when running status queriesznetbios namer
   r   )getr   )lps    r   netcmd_dnsnamer"   G   s7     66.!'')C/"&&/2G2G2IIIr   c                     [        XS9nUc  U R                  S5      nUR                  U[        R                  [        R
                  -  [        R                  -  S9nUR                  $ )zReturn domain-name of a writable/ldap-capable DC for the default
domain (parameter "realm" in smb.conf) unless another realm has been
specified as argumentcredsr!   r   )r   flags)r   r    finddcr   NBT_SERVER_LDAPNBT_SERVER_DSNBT_SERVER_WRITABLEpdc_dns_name)r!   r%   r   net	cldap_rets        r   netcmd_finddcr.   M   sa     E
!C}w

%!$!4!4s7H7H!H3KbKb!b  dI!!!r   c                 v    [        XS9nUR                  U[        R                  [        R                  -  S9nU$ )zZReturn domain information (CLDAP record) of the ldap-capable
DC with the specified addressr$   )addressr&   )r   r'   r   r(   r)   )r!   r%   r0   r,   r-   s        r   !netcmd_get_domain_infos_via_cldapr1   Y   s>     E
!C

7!$!4!4s7H7H!H  JIr   c                 x    SS K n [        U 5      nU H  nUR                  U5      S   S:X  d  M    g   g!    g= f)Nr   FCT)unicodedatastrcategory)valr4   str_valcs       r   is_printable_attr_valr:   a   sI    c( "1%,  s   5 9c                 r   [         R                  " 5       nUR                  Ul        UR                  5        H\  nUS:X  a  M  X   nXBU'   SnU H  n[	        U5      (       a  M  Sn  O   U(       a  M;  X#   R                  [         R                  5        M^     U R                  U[         R                  5      nU$ )NdnFT)	ldbMessager<   keysr:   	set_flagsFLAG_FORCE_NO_BASE64_LDIF
write_ldifCHANGETYPE_NONE)samdbmsgr   kvalsneed_base64vresult_ldifs           r   get_ldif_for_editorrK   s   s     	A66ADXXZ9v!A$Q''K	 
 {DNN3889  ""1c&9&9:Kr   c                 X    [        U 5      [        :X  a  g[        [        U 5      5      S-  $ )z8Converts a timestamp in -100 nanosecond units to minutesr   g    A)intNEVER_TIMESTAMPabstimestamp_strs    r   timestamp_to_minsrR      s)    
 =_,3}%&(33r   c                     [        U 5      S-  $ )z5Converts a timestamp in -100 nanosecond units to daysi  )rR   rP   s    r   timestamp_to_daysrT      s    ]+w77r   c                     X;   a  X   S   $ U$ )z/get an attribute from a ldap msg with a defaultr    )rE   attrnamedefaults      r   attr_defaultrY      s    }QNr   )N)r   samba.dcerpcr   	samba.netr   samba.netcmdr   r=   rM   rN   r   r"   r.   r1   r:   rK   rR   rT   rY   rV   r   r   <module>r]      sR   ( 
   % 
 )*%1PJ	"$448
r   