
Vc           @   ss  d  d l  j Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 Z
 d  d l m Z d  d l m Z m Z d  d l Z d  d l m Z m Z m Z d  d l m Z d  d l m Z d  d l m Z m Z m Z d  d l m Z d  d	 l m Z d  d
 l m  Z  d  d l m! Z! d  d l m" Z" d  d l m# Z# d  d l$ m% Z% m& Z& d  d l' m( Z( m) Z) m* Z* m+ Z+ d  d l, m- Z- d  d l. m/ Z/ d  d l. m0 Z1 d  d l2 m3 Z3 d  d l4 m5 Z5 m6 Z6 m7 Z7 m8 Z8 d  d l m9 Z9 m: Z: d  d l; m< Z< m= Z= m> Z> m? Z? m@ Z@ mA ZA mB ZB mC ZC mD ZD mE ZE d  d lF mG ZG mH ZH d  d lI mJ ZJ mK ZK mL ZL d   ZM y d  d lN Z Wn eO k
 reP ZQ n Xd e( f d     YZQ d e( f d     YZR d e( f d     YZS d  e( f d!     YZT d" e( f d#     YZU d$ e( f d%     YZV d& e( f d'     YZW d( e( f d)     YZX d* e( f d+     YZY d, eY f d-     YZZ d. e j[ f d/     YZ\ d0 e( f d1     YZ] d2 e] f d3     YZ^ d4 e] f d5     YZ_ d6 e] f d7     YZ` d8 e] f d9     YZa d: e] f d;     YZb d< e] f d=     YZc d> e* f d?     YZd d@ e* f dA     YZe d S(B   iN(   t   getpass(   t   Nett   LIBNET_JOIN_AUTOMATIC(   t	   join_RODCt   join_DCt   join_subdomain(   t   system_session(   t   SamDB(   t
   ndr_unpackt   ndr_packt	   ndr_print(   t   drsuapi(   t   drsblobs(   t   lsa(   t   netlogon(   t   security(   t   nbt(   t   DOMAIN_PASSWORD_COMPLEXt   DOMAIN_PASSWORD_STORE_CLEARTEXT(   t   Commandt   CommandErrort   SuperCommandt   Option(   t!   netcmd_get_domain_infos_via_cldap(   t   Samba3(   t   param(   t   upgrade_from_samba3(   t   sendDsReplicaSynct   drsuapi_connectt   drsExceptiont   sendRemoveDsServer(   t   arcfour_encryptt   string_to_byte_array(
   t   DS_DOMAIN_FUNCTION_2000t   DS_DOMAIN_FUNCTION_2003t   DS_DOMAIN_FUNCTION_2003_MIXEDt   DS_DOMAIN_FUNCTION_2008t   DS_DOMAIN_FUNCTION_2008_R2t$   DS_NTDSDSA_OPT_DISABLE_OUTBOUND_REPLt#   DS_NTDSDSA_OPT_DISABLE_INBOUND_REPLt   UF_WORKSTATION_TRUST_ACCOUNTt   UF_SERVER_TRUST_ACCOUNTt   UF_TRUSTED_FOR_DELEGATION(   t	   provisiont   ProvisioningError(   t	   FILL_FULLt   FILL_NT4SYNCt   FILL_DRSc         C   s5   d |  | | f } t  j | d  j   } | j   S(   Ns-   %s -s -l --parameter-name='%s' %s 2>/dev/nullt   r(   t   ost   popent   readlinet   strip(   t   testparmt   smbconft   varnamet   cmdt   output(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   get_testparm_varW   s    t   cmd_domain_export_keytabc           B   sq   e  Z d  Z d Z i e j d 6e j d 6e j d 6Z e	 d d d d e
 g Z d	 g Z d d d d d
  Z RS(   s/   Dump Kerberos keys of the domain into a keytab.s   %prog <keytab> [options]t	   sambaoptst   credoptst   versionoptss   --principalt   helps   extract only this principalt   typet   keytabc         C   s5   | j    } t d  |  } | j d | d |  d  S(   NRA   t	   principal(   t   get_loadparmR   t   Nonet   export_keytab(   t   selfRA   R=   R<   R>   RB   t   lpt   net(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   runr   s    N(   t   __name__t
   __module__t   __doc__t   synopsist   optionst   SambaOptionst   CredentialsOptionst   VersionOptionst   takes_optiongroupsR   t   strt   takes_optionst
   takes_argsRD   RI   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR;   a   s   

	t   cmd_domain_infoc           B   sY   e  Z d  Z d Z g  Z i e j d 6e j d 6e j d 6Z	 d g Z
 d d d d  Z RS(   s?   Print basic info about a domain and the DC passed as parameter.s   %prog <ip_address> [options]R<   R=   R>   t   addressc         C   s   | j    } y t | d  |  } Wn% t k
 rI t d | d   n X|  j j d | j  |  j j d | j  |  j j d | j	  |  j j d | j
  |  j j d | j  |  j j d | j  |  j j d	 | j  d  S(
   Ns   Invalid IP address 's   '!s   Forest           : %s
s   Domain           : %s
s   Netbios domain   : %s
s   DC name          : %s
s   DC netbios name  : %s
s   Server site      : %s
s   Client site      : %s
(   RC   R   RD   t   RuntimeErrorR   t   outft   writet   forestt
   dns_domaint   domain_namet   pdc_dns_namet   pdc_namet   server_sitet   client_site(   RF   RW   R=   R<   R>   RG   t   res(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRI      s    N(   RJ   RK   RL   RM   RT   RN   RO   RP   RQ   RR   RU   RD   RI   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRV   x   s   

	t   cmd_domain_provisionc        (   B   s  e  Z d  Z d Z i e j d 6e j d 6Z e d d d d d e d	 d
 d d d d d e d d
 d d d d d e d d
 d d d d d e d d
 d d d d d e d d
 d d d d d e d d
 d d d d d e d d
 d d d d d e d d
 d d d  d d! e d" d
 d d d# d d$ e d% d
 d d d& d d' e d( d
 d d d& d d) e d* d
 d d d& d d+ e d, d
 d- d d. d/ d0 d1 d2 d3 g d d4 d5 d0 e d6 d
 d d d& d d7 e d8 d
 d d d& d d9 e d: d
 d d d; d d< e d= d
 d d d; d d> e d? d
 d d d@ d dA e dB d dC d d e dD d d d dE e dF d
 d- d dG d dH d/ dI dJ g e dK d
 d- d dL d/ dM dN dO dP dQ g d dR d5 dM e dS d
 d- d dT d/ dU dV dW dX g d dY d5 dX e dZ d
 d[ d d\ d5 d] d d^ e d_ d d` d d e da d
 d d db d dc e dd d
 d d de d df e dg d
 d- d/ dh di dj g d dk d5 dj e dl d d d dm e dn d d d do g Z	 e dp d dq d d e dr d
 d d ds d dt e du d
 d[ d dv d dw e dx d
 d d dy d dz e d{ d d| d d g Z
 e j d} di  dh k rhe	 j e
  n  g  Z d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d~ ' Z d   Z RS(   s   Provision a domain.s   %prog [options]R<   R>   s   --interactiveR?   s   Ask for namest   actiont
   store_trues   --domainR@   t   stringt   metavart   DOMAINs
   set domains   --domain-guidt   GUIDs!   set domainguid (otherwise random)s   --domain-sidt   SIDs    set domainsid (otherwise random)s   --ntds-guids'   set NTDS object GUID (otherwise random)s   --invocationids#   set invocationid (otherwise random)s   --host-namet   HOSTNAMEs   set hostnames	   --host-ipt	   IPADDRESSs   set IPv4 ipaddresss
   --host-ip6t
   IP6ADDRESSs   set IPv6 ipaddresss   --sitet   SITENAMEs   set site names   --adminpasst   PASSWORDs(   choose admin password (otherwise random)s   --krbtgtpasss)   choose krbtgt password (otherwise random)s   --machinepasss*   choose machine password (otherwise random)s   --dns-backendt   choices   NAMESERVER-BACKENDt   choicest   SAMBA_INTERNALt   BIND9_FLATFILEt	   BIND9_DLZt   NONEs   The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), BIND9_FLATFILE uses bind9 text database to store zone information, BIND9_DLZ uses samba4 AD to store zone information, NONE skips the DNS setup entirely (not recommended)t   defaults	   --dnspasss&   choose dns password (otherwise random)s   --ldapadminpasssM   choose password to set between Samba and it's LDAP backend (otherwise random)s   --roott   USERNAMEs   choose 'root' unix usernames   --nobodys   choose 'nobody' users   --userst	   GROUPNAMEs   choose 'users' groups   --quiets   Be quiets   --blanks.   do not add users or groups, just the structures   --ldap-backend-types   LDAP-BACKEND-TYPEs`   Test initialisation support for unsupported LDAP backend type (fedora-ds or openldap) DO NOT USEs	   fedora-dst   openldaps   --server-rolet   ROLEs   domain controllert   dcs   member servert   membert
   standalones^   The server role (domain controller | dc | member server | member | standalone). Default is dc.s   --function-levels   FOR-FUN-LEVELt   2000t   2003t   2008t   2008_R2sy   The domain and forest function level (2000 | 2003 | 2008 | 2008_R2 - always native). Default is (Windows) 2008_R2 Native.s
   --next-ridt   intt   NEXTRIDi  sG   The initial nextRid value (only needed for upgrades).  Default is 1000.s   --partitions-onlysE   Configure Samba's partitions, but do not modify them (ie, join a BDC)s   --targetdirt   DIRs   Set target directorys   --ol-mmr-urlst
   LDAPSERVERs   List of LDAP-URLS [ ldap://<FQHN>:<PORT>/  (where <PORT> has to be different than 389!) ] separated with comma (",") for use with OpenLDAP-MMR (Multi-Master-Replication), e.g.: "ldap://s4dc1:9000,ldap://s4dc2:9000"s   --use-xattrst   yest   not   autos   Define if we should use the native fs capabilities or a tdb file for storing attributes likes ntacl, auto tries to make an inteligent guess based on the user rights and system capabilitiess   --use-ntvfss+   Use NTVFS for the fileserver (default = no)s   --use-rfc2307s/   Use AD to store posix attributes (default = no)s   --ldap-dryrun-modest   Configure LDAP backend, but do not run any binaries and exit early.  Used only for the test environment.  DO NOT USEs   --slapd-paths
   SLAPD-PATHs   Path to slapd for LDAP backend [e.g.:'/usr/local/libexec/slapd']. Required for Setup with LDAP-Backend. OpenLDAP Version >= 2.4.17 should be used.s   --ldap-backend-extra-ports   LDAP-BACKEND-EXTRA-PORTsD   Additional TCP port for LDAP backend server (to use for replication)s   --ldap-backend-forced-uris   LDAP-BACKEND-FORCED-URIs   Force the LDAP backend connection to be to a particular URI.  Use this ONLY for 'existing' backends, or when debugging the interaction with the LDAP backend and you need to intercept the LDAs   --ldap-backend-nosyncsQ   Configure LDAP backend not to call fsync() (for performance in test environments)t	   TEST_LDAPc(   9   Q   C   sn  |  j  d  |  _ | r. |  j j t j  n |  j j t j  | j   }( |( j }) | d  k	 rk | }* n! |  j	   }* |* d  k r d }* n  t
 |  j  d k r t } n  | r|d d l m }+ d d  l }, d  d  }- y& |, j   j d d  d j   }. Wn t k
 rd  }. n X|- d |.  }/ |/ dR k rBt d
   n  y |/ j d  d }. Wn t k
 rrd  }. n X|- d |.  } | d  k rt d   n  |- d d  } |- d d  } | dS k rt d   n  | d k r|- d |*  } | j   dT k rd  }* d  } qn  x t rx|+ d  }0 |0 sC|  j j d  q|+ d  }1 |0 |1 k sn|  j j d  q|0 } PqWnH | j j d  }/ |/ d  k rt d
   n  | d  k rt d   n  | s|  j j d  n  | d k rt }2 n? | d k rt }2 n* | d k rt }2 n | d k r1t }2 n  | d k rR| d  k rR|* } n  t }3 | rgt }3 n | rvt  }3 n  | d  k	 rt! j" j# |  st! j$ |  qn  t }4 |  d k rt% }4 n |  d k r|( j d   r| rt& j' d! t! j" j( |   }5 n3 t& j' d! t! j" j( t! j" j) |( j d"     }5 zQ y) t* j+ j, |( |5 j- d# d$ d%  t% }4 Wn! t. k
 r|  j j d&  n XWd  |5 j/   Xn  |4 r|  j j d'  n  | d( k r|& d  k	 r|  j j0 d) |&  q|  j j d*  n |& d  k	 r|  j j0 d+  n  | d  k	 r2t1 j2 |  } n  t3   }6 y t4 |  j |6 d, |) d- | d. |3 d |/ d/ | d0 | d1 | d2 |	 d3 |
 d4 | d5 | d6 | d7 | d8 | d9 | d: | d; | d< | d= | d> | d? | d@ | dA | dB |2 dC | dD | dE | dF |! dG |4 dH | dI |( dJ |" dK |# dL t% dM |% dN |& dO |$ dP |' &}7 Wn" t5 k
 rY}8 t dQ |8   n X|7 j6 |  j  d  S(U   NR+   t   nonei   i(   R    c         S   sD   | d  k	 r d |  | f Gn d |  f Gt j j   j d  pC | S(   Ns	   %s [%s]: s   %s: s   
(   RD   t   syst   stdinR3   t   rstrip(   t   promptRv   (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   ask5  s    t   .t   Realmt    s   No realm set!i    t   Domains   No domain set!s$   Server Role (dc, member, standalone)R{   s=   DNS backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ, NONE)Rr   s   No DNS backend set!s=   DNS forwarder IP address (write 'none' to disable forwarding)s   Administrator password: s    Invalid administrator password.
s   Retype password: s   Sorry, passwords do not match.
t   realms,   Administrator password will be set randomly!R~   R   R   R   R   R   s
   posix:eadbt   dirs   private dirs   O:S-1-5-32G:S-1-5-32s   S-1-5-32t   nativesX   You are not root or your system do not support xattr, using tdb backend for attributes. s   not using extended attributes to store ACLs and other metadata. If you intend to use this provision in production, rerun the script as root on a system supporting xattrs.t   existingsr   You have specified to use an existing LDAP server as the backend, please make sure an LDAP server is running at %ss   You have specified to use an existing LDAP server as the backend, please make sure an LDAP server is running at the default locations   You have specified to use an fixed URI %s for connecting to your LDAP server backend.  This is NOT RECOMMENDED, as our default communiation over ldapi:// is more secure and much lessR6   t	   targetdirt
   samdb_fillt   domaint
   domainguidt	   domainsidt   hostnamet   hostipt   hostip6t   sitenamet   ntdsguidt   invocationidt	   adminpasst
   krbtgtpasst   machinepasst   dns_backendt   dns_forwardert   dnspasst   roott   nobodyt   userst
   serverrolet   dom_for_fun_levelt   backend_typet   ldapadminpasst   ol_mmr_urlst
   slapd_patht   useeadbt   next_ridRG   t	   use_ntvfst   use_rfc2307t   skip_sysvolaclt   ldap_backend_extra_portt   ldap_backend_forced_urit   nosynct   ldap_dryrun_modes   Provision failed(   NR   (   NR   (   NR   (7   t
   get_loggert   loggert   setLevelt   loggingt   WARNINGt   INFORC   t
   configfileRD   t   _get_nameserver_ipt   lent   raw_argvt   TrueR    t   sockett   getfqdnt   splitt   uppert
   IndexErrorR   t   lowert   errfRZ   t   _lpt   gett   infoR!   R"   R$   R%   R-   R.   R/   R1   t   patht   isdirt   mkdirt   Falset   tempfilet   NamedTemporaryFilet   abspatht   dirnamet   sambat   ntaclst   setntaclt   namet	   Exceptiont   closet   warnR   t   dom_sidR   R+   R,   t   report_logger(9   RF   R<   R>   t   interactiveR   t   domain_guidt
   domain_sidt	   ntds_guidR   t	   host_namet   host_ipt   host_ip6R   t   siteR   R   R   R   R   R   R   R   R   t   quiett   blankt   ldap_backend_typet   server_rolet   function_levelR   t   partitions_onlyR   R   t
   use_xattrsR   R   R   t   ldap_backend_nosyncR   R   R   RG   R6   t   suggested_forwarderR    R   R   Rv   R   t   adminpassplaint   adminpassverifyR   R   t   eadbt   filet   sessiont   resultt   e(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRI      s    '				&

									!3
		c         C   s   d d l  m } d } | j |  s= |  j j d |  d Sd } zJ t | d  } x4 | D], } | j d  sw q\ n  | j   j	   d SWWd | d k	 r | j
   n  X|  j j d |  d S(	   s5   Grab the nameserver IP address from /etc/resolv.conf.i(   R   s   /etc/resolv.confs   Failed to locate %sR0   t
   nameserverNs   No nameserver found in %s(   R1   R   t   isfileR   t   warningRD   t   opent
   startswithR4   R   R   (   RF   R   t   RESOLV_CONFt   handlet   line(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR     s    N(   RJ   RK   RL   RM   RN   RO   RQ   RR   R   RT   t   openldap_optionsR1   t   getenvt   extendRU   RD   RI   R   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRc      s   
	*t   cmd_domain_dcpromoc           B   s[  e  Z d  Z d Z i e j d 6e j d 6e j d 6Z e	 d d d d e
 e	 d	 d d
 d e
 e	 d d d d e
 e	 d d d d d e	 d d e
 d d d d e	 d d d d d e	 d d d d d d d d d g d d d d e	 d  d d! d d e	 d" d d# d d g	 Z d$ d% g Z d' d' d' d' d' d' d' e d' d' e d' e e d&  Z RS((   s9   Promote an existing domain member or NT4 PDC to an AD DC.s%   %prog <dnsdomain> [DC|RODC] [options]R<   R>   R=   s   --serverR?   s
   DC to joinR@   s   --sites   site to joins   --targetdirs   where to store provisions   --domain-critical-onlys&   only replicate critical domain objectsRd   Re   s   --machinepassRg   Ro   s*   choose machine password (otherwise random)s   --use-ntvfss+   Use NTVFS for the fileserver (default = no)s   --dns-backendRp   s   NAMESERVER-BACKENDRq   Rr   Rt   Ru   s   The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), BIND9_DLZ uses samba4 AD to store zone information, NONE skips the DNS setup entirely (this DC will not be a DNS server)Rv   s   --quiets   Be quiets	   --verboses
   Be verboseR   s   role?c         C   s  | j    } | j |  } t | | d | j } | d  k rH d } n  |  j   } | rm | j t j  n) | r | j t j	  n | j t j
  | j d  } | d  k	 r | j   } n  | d k r$t d | d | d | d | d | d	 | d
 | d | d |	 d | d | d | d t  nt | d k rt d | d | d | d | d | d	 | d
 | d | d |	 d | d | d | d t  n t d |   d  S(   Nt   servers   Default-First-Site-Names   netbios namet   DCR   t   credsRG   R   R   t   netbios_nameR   t   domain_critical_onlyR   R   R   t   promote_existingt   RODCs-   Invalid role '%s' (possible values: DC, RODC)(   RC   t   get_credentialsR   t	   ipaddressRD   R   R   R   t   DEBUGR   R   R   R   R   R   R   R   (   RF   R   t   roleR<   R=   R>   R  R   R   R	  t   parent_domainR   R   R   R   t   verboseRG   R  RH   R   R  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRI     s8    	$
$
N(   RJ   RK   RL   RM   RN   RO   RQ   RP   RR   R   RS   RT   RU   RD   R   RI   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    s8   

			t   cmd_domain_joinc           B   s  e  Z d  Z d Z i e j d 6e j d 6e j d 6Z e	 d d d d e
 e	 d	 d d
 d e
 e	 d d d d e
 e	 d d d d e
 e	 d d d d d e	 d d e
 d d d d e	 d d d d d d d e	 d d d d d e	 d d d d d d d  d! d" g d d# d$ d  e	 d% d d& d d e	 d' d d( d d g Z d) d* g Z d, d, d, d, d, d, d, e d, d, e d, d, e e d+  Z RS(-   s9   Join domain as either member or backup domain controller.s6   %prog <dnsdomain> [DC|RODC|MEMBER|SUBDOMAIN] [options]R<   R>   R=   s   --serverR?   s
   DC to joinR@   s   --sites   site to joins   --targetdirs   where to store provisions   --parent-domains'   parent domain to create subdomain unders   --domain-critical-onlys&   only replicate critical domain objectsRd   Re   s   --machinepassRg   Ro   s*   choose machine password (otherwise random)s   --adminpassRf   sK   choose adminstrator password when joining as a subdomain (otherwise random)s   --use-ntvfss+   Use NTVFS for the fileserver (default = no)s   --dns-backendRp   s   NAMESERVER-BACKENDRq   Rr   Rt   Ru   s   The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), BIND9_DLZ uses samba4 AD to store zone information, NONE skips the DNS setup entirely (this DC will not be a DNS server)Rv   s   --quiets   Be quiets	   --verboses
   Be verboseR   s   role?c         C   s  | j    } | j |  } t | | d | j } | d  k rH d } n  |  j   } | rm | j t j  n) | r | j t j	  n | j t j
  | j d  } | d  k	 r | j   } n  | d  k s | d k r| j | | t d | \ } } } |  j j d | | f  n| d k rwt d | d | d	 | d
 | d | d | d | d | d |	 d | d | d |  n(| d k rt d | d | d	 | d
 | d | d | d | d | d |	 d | d | d |  n | d k r| s| j d  n  | j d  } |
 d  k r1d j | j d  d  }
 n  t d | d | d	 | d
 | d | d |
 d | d | d | d | d | d | d | d |  n t d |   d  S(   NR  s   Default-First-Site-Names   netbios namet   MEMBERR   s   Joined domain %s (%s)
R  R   R  RG   R   R   R  R   R	  R   R   R  t	   SUBDOMAINs,   Administrator password will be set randomly!t	   workgroupR   i   t	   dnsdomainR  t   netbios_domainR   s@   Invalid role '%s' (possible values: MEMBER, DC, RODC, SUBDOMAIN)(   RC   R  R   R  RD   R   R   R   R  R   R   R   R   t   join_memberR   R   RZ   R   R   R   t   joinR   R   R   (   RF   R   R  R<   R=   R>   R  R   R   R	  R  R   R   R   R   R   R  RG   R  RH   R   R  t   join_passwordt   sidR]   R  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRI   J  sV    	$$
$
N(   RJ   RK   RL   RM   RN   RO   RQ   RP   RR   R   RS   RT   RU   RD   R   RI   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR  %  s>   

				t   cmd_domain_demotec           B   s   e  Z d  Z d Z e d d d d e e d d d d e g Z i e j d 6e j	 d	 6e j
 d
 6Z d d d d d d  Z RS(   s4   Demote ourselves from the role of Domain Controller.s   %prog [options]s   --serverR?   s%   DC to force replication before demoteR@   s   --targetdirs   where provision is storedR<   R=   R>   c   $      C   s
  | j    } | j |  } t | | d | j } | j d  }	 t d t   d | d |  }
 | s|
 j d d d d	 d
 g  } t |  d k r t	 d   n  t |  d k r t	 d   n  d  } xA | D]6 } t | d
  j   |	 j   k r | d	 } Pq q Wn  |
 j   } |
 j d t |
 j    d t j d d | d d g  } t |  d k sxd | d k rt	 d |   n  | d j } t t | d d   } |
 j d d t |  d d g  } t |  d k rt	 d t |    n  |  j j d |  t | | |  \ } } } |  j j d  t j   } | d j | _ | t O} t j t |  t j d  | d <|
 j |  | t @r|
 j   r|  j j d |  x |
 j   |
 j   |
 j   f D] } y# t | | | t |  t  j!  Wqt" k
 r} |  j j d  | t N} t j t |  t j d  | d <|
 j |  t	 d t |  |   qXqWn  y t d d | d t   d | d |  } |  j j d  | j d t | j    d d  |	 j#   d d! g  } | d j } t t | d d!   } Wnk t$ k
 r} |  j j d  | t N} t j t |  t j d  | d <|
 j |  t	 d" |   n Xt |  d k r|  j j d#  | t N} t j t |  t j d  | d <|
 j |  t	 d$ |	 j#     n  | } | t% t& BN} | t' O} t j   } | | _ t j d% | t j d!  | d! <y | j |  Wnk t$ k
 r} |  j j d#  | t N} t j t |  t j d  | d <|
 j |  t	 d" |   n X| j j(   } t | d j  } t) j* | d& t |  d'  } d } | } t j+ | d( t | j     } | j d | d | d t j,  } t |  d k r| j d | d d) | | f d t j,  } xW t |  d k r | d* k  r | d } | j d | d d) | | f d t j,  } qW| d* k r|  j j d  | t N} t j t |  t j d  | d <|
 j |  t j   } | | _ t j d% | t j d!  | d! <| j |  t	 d+ t |  | | | d, f   n  d) | | f } n  y6 t j+ | d- | t |  f  } | j- | |  Wn t$ k
 r} |  j j d  | t N} t j t |  t j d  | d <|
 j |  t j   } | | _ t j d% | t j d!  | d! <| j |  t	 d. t |  t |  f |   n X|
 j.   }  | j   }! y t/ | | |  |!  Wn t" k
 r	} |  j j d  | t N} t j t |  t j d  | d <|
 j |  t j   } | | _ t j d% | t j d!  | d! <t |  GH| j |  | j- | |  t	 d/ |   n Xxy d0 d1 | j d2  d3 f D][ }" y< | j0 t j+ | d4 t |  |" t | j    f   Wq	t j1 k
 rA
}# q	Xq	Wxm d5 d6 | j d2  d7 d8 f D]L }" y- | j0 t j+ | d- |" t |  f   Wqf
t j1 k
 r
}# qf
Xqf
W|  j j d9  d  S(:   NR  s   netbios namet   session_infot   credentialsRG   t
   expressions.   (&(objectClass=computer)(serverReferenceBL=*))t   attrst   dnsHostNameR   i    s   Unable to search for serversi   s'   You are the latest server in the domaint   baset   scopes   (objectGUID=%s)RN   s   Failed to find options on %ss   (fSMORoleOwner=%s)t   controlss   search_options:1:2sa   Current DC is still the owner of %d role(s), use the role command to transfer roles to another DCs,   Using %s as partner server for the demotion
s!   Deactivating inbound replication
s0   Asking partner server %s to synchronize from us
s6   Error while demoting, re-enabling inbound replication
s2   Error while sending a DsReplicaSync for partion %st   urls	   ldap://%ss#   Changing userControl and container
s)   (&(objectClass=user)(sAMAccountName=%s$))t   userAccountControls$   Error while changing account controls5   Error while demoting, re-enabling inbound replications@   Unable to find object with samaccountName = %s$ in the remote dcs   %ds   ,%sR   s   CN=Computers,%ss   %s-%did   sO   Unable to find a slot for renaming %s, all names from %s-1 to %s-%d seemed usedi	   s   %s,%ss   Error while renaming %s to %ss$   Error while sending a removeDsServersD   CN=Enterprise,CN=Microsoft System Volumes,CN=System,CN=Configurations<   CN=%s,CN=Microsoft System Volumes,CN=System,CN=ConfigurationR   sM   CN=Domain System Volumes (SYSVOL share),CN=File Replication Service,CN=Systems   %s,%s,%ss$   CN=Enterprise,CN=NTFRS Subscriptionss   CN=%s, CN=NTFRS Subscriptionss?   CN=Domain system Volumes (SYSVOL Share), CN=NTFRS Subscriptionss   CN=NTFRS Subscriptionss   Demote successful
(2   RC   R  R   R  R   R   R   t   searchR   R   RD   RS   R   t   get_ntds_GUIDt   get_config_basednt   ldbt   SCOPE_SUBTREEt   dnR   R   RZ   R   t   MessageR'   t   MessageElementt   FLAG_MOD_REPLACEt   modifyR&   t   am_rodct   get_schema_basednt   get_root_basednR   R   t   DRSUAPI_DRS_WRIT_REPR   R   R   R)   R*   R(   t   parentRf   t   replacet   Dnt   SCOPE_ONELEVELt   renamet   get_serverNameR   t   deletet   LdbError($   RF   R<   R=   R>   R  R   RG   R  RH   R  t   samdbRb   R   R   t   msgt   ntds_dnt   dsa_optionst   drsuapiBindt   drsuapi_handlet   supportedExtensionst   nmsgt   partt   remote_samdbt   dc_dnt   uact   olduacR5  t   rdnt   it   newrdnt   computer_dnt   newdnt   server_dsa_dnR   t   st   l(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRI     sb   "
"
"	#	
"$		
"	
"
		
""!!
	
"	#"	
"	)	
"	-N(   RJ   RK   RL   RM   R   RS   RT   RN   RO   RP   RQ   RR   RD   RI   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    s   

t   cmd_domain_levelc           B   s   e  Z d  Z d Z i e j d 6e j d 6e j d 6Z e	 d d d d d	 e
 d
 d d d e	 d d d d d e	 d d	 d d d d d g d d e	 d d	 d d d d d g d d g Z d g Z d d d e d d d d  Z RS(   s(   Raise domain and forest function levels.s&   %prog (show|raise <options>) [options]R<   R=   R>   s   -Hs   --URLR?   s%   LDB URL for database or target serverR@   Rg   t   URLt   destt   Hs   --quiets   Be quietRd   Re   s   --forest-levelRp   Rq   R   R   R   s1   The forest function level (2003 | 2008 | 2008_R2)s   --domain-levels1   The domain function level (2003 | 2008 | 2008_R2)t
   subcommandc	      	   C   sW  | j    }	 | j |	 d t }
 t d | d t   d |
 d |	  } | j   } | j d | j   d t j	 d d	 g } t
 |  d
 k s t  | j | d t j	 d d	 d g } t
 |  d
 k s t  | j d | j   d t j d d d d	 g } t
 |  d
 k st  yt | d d	 d  } t | d d	 d  } t | d d d  } t | d d	 d  } x? | D]7 } t | d	 d  | k  rt | d	 d  } qqW| d k  s| d k  rt d   n  | d k  r t d   n  | | k rt d   n  | | k r6t d   n  Wn t k
 rVt d   n X| d k r|  j d |  | t k r| d k r|  j d  n  | t k r| d k r|  j d  n  | t k r| d k r|  j d  n  |  j d  | t k rd } nZ | t k r#d } nE | t k r8d } n0 | t k rMd } n | t k rbd } n d  } |  j d! |  | t k r| d k rd" } n{ | t k r| d k rd } nZ | t k rd } nE | t k rd } n0 | t k rd } n | t k rd } n d  } |  j d# |  | t k r;d } nE | t k rPd } n0 | t k red } n | t k rzd } n d  } |  j d$ |  n| d% k rCg  } | d  k	 r2| d k rt } n* | d k rt } n | d& k rt } n  | | k r| d k rt d'   n  | | k r3t d(   n  | d k r)t j   } t j | |  | _ t j d) t j d  | d <| j |  t j   } t j | d* |	 j d+  d, | j    | _ t j d) t j d  | d <y | j |  Wq)t j k
 r%\ } } | t j k r&  q&q)Xn  t j   } t j | |  | _ t j t  |  t j d	  | d	 <| j |  t j   } t j | d* |	 j d+  d, | j    | _ t j t  |  t j d	  | d	 <y | j |  Wn1 t j k
 r\ } } | t j k r  qn X| } | j! d-  n  | d  k	 r| d k rSt } n* | d k rht } n | d& k r}t } n  | | k rt d.   n  | | k rt d/   n  t j   } t j | d | j    | _ t j t  |  t j d	  | d	 <| j |  | j! d0  n  | j! d1  |  j d2 j" |   n t d3 |   d  S(4   Nt   fallback_machineR%  R  R  RG   s   CN=Partitions,%sR#  R   s   msDS-Behavior-Versioni   t   nTMixedDomains   CN=Sites,%sR  s   (objectClass=nTDSDSA)i    sS   Domain and/or forest function level(s) is/are invalid. Correct them or reprovision!sF   Lowest function level of a DC is invalid. Correct this or reprovision!sV   Forest function level is higher than the domain level(s). Correct this or reprovision!sd   Domain function level is higher than the lowest function level of a DC. Correct this or reprovision!sS   Could not retrieve the actual domain, forest level and/or lowest DC function level!t   shows0   Domain and forest function level for domain '%s's|   
ATTENTION: You run SAMBA 4 on a forest function level lower than Windows 2000 (Native). This isn't supported! Please raise!s|   
ATTENTION: You run SAMBA 4 on a domain function level lower than Windows 2000 (Native). This isn't supported! Please raise!s   
ATTENTION: You run SAMBA 4 on a lowest function level of a DC lower than Windows 2003. This isn't supported! Please step-up or upgrade the concerning DC(s)!R   R~   s0   2003 with mixed domains/interim (NT4 DC support)R   R   s   2008 R2s   higher than 2008 R2s!   Forest function level: (Windows) s   2000 mixed (NT4 DC support)s!   Domain function level: (Windows) s)   Lowest function level of a DC: (Windows) t   raiseR   sG   Domain function level can't be smaller than or equal to the actual one!sM   Domain function level can't be higher than the lowest function level of a DC!t   0s   CN=R  s   ,CN=Partitions,%ss   Domain function level changed!sG   Forest function level can't be smaller than or equal to the actual one!sd   Forest function level can't be higher than the domain function level(s). Please raise it/them first!s   Forest function level changed!s!   All changes applied successfully!s   
s4   invalid argument: '%s' (choose from 'show', 'raise')(#   RC   R  R   R   R   t	   domain_dnR'  R)  R*  t
   SCOPE_BASER   t   AssertionErrorR+  R   R   t   KeyErrort   messageR!   R#   R"   R$   R%   RD   R-  R7  R,  R.  R/  R0  R   R<  t   ERR_UNWILLING_TO_PERFORMRS   t   appendR  (   RF   RV  RU  t   forest_levelt   domain_levelR   R=   R<   R>   RG   R  R=  R\  t
   res_forestt
   res_domaint   res_dc_st   level_forestt   level_domaint   level_domain_mixedt   min_level_dcR>  t   outstrt   msgst   new_level_domaint   mt   enumt   emsgt   new_level_forest(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRI     s$   																			0		'
			N(   RJ   RK   RL   RM   RN   RO   RP   RQ   RR   R   RS   RT   RU   RD   R   RI   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRR  w  s    

		t   cmd_domain_passwordsettingsc           B   s  e  Z d  Z d Z i e j d 6e j d 6e j d 6Z e	 d d d d d	 e
 d
 d d d e	 d d d d d e	 d d	 d d d d d g d d e	 d d	 d d d d d g d d e	 d d d d	 e
 e	 d d d d	 e
 e	 d d d  d	 e
 e	 d! d d" d	 e
 e	 d# d d$ d	 e
 e	 d% d d& d	 e
 e	 d' d d( d	 e
 g Z d) g Z d+ d+ d+ e d+ d+ d+ d+ d+ d+ d+ d+ d+ d+ d*  Z RS(,   s  Set password settings.

    Password complexity, password lockout policy, history length,
    minimum password length, the minimum and maximum password age) on
    a Samba AD DC server.

    Use against a Windows DC is possible, but group policy will override it.
    s$   %prog (show|set <options>) [options]R<   R>   R=   s   -Hs   --URLR?   s%   LDB URL for database or target serverR@   Rg   RS  RT  RU  s   --quiets   Be quietRd   Re   s   --complexityRp   Rq   t   ont   offRv   s=   The password complexity (on | off | default). Default is 'on's   --store-plaintexts   Store plaintext passwords where account have 'store passwords with reversible encryption' set (on | off | default). Default is 'off's   --history-lengthsB   The password history length (<integer> | default).  Default is 24.s   --min-pwd-lengthsA   The minimum password length (<integer> | default).  Default is 7.s   --min-pwd-agesF   The minimum password age (<integer in days> | default).  Default is 1.s   --max-pwd-agesG   The maximum password age (<integer in days> | default).  Default is 43.s   --account-lockout-durations   The the length of time an account is locked out after exeeding the limit on bad password attempts (<integer in mins> | default).  Default is 30 mins.s   --account-lockout-thresholds   The number of bad password attempts allowed before locking out the account (<integer> | default).  Default is 0 (never lock out).s   --reset-account-lockout-aftersu   After this time is elapsed, the recorded number of attempts restarts from zero (<integer> | default).  Default is 30.RV  c   %      C   s  | j    } | j |  } t d | d t   d | d |  } | j   } | j | d t j d d d d	 d
 d d d d g } t |  d k s t	  yFt
 | d d d  } t
 | d d d  } t
 | d d	 d  } t
 t t
 | d d
 d   dF  } t
 | d d d  d k r3d } n( t
 t t
 | d d d   dI  } t
 | d d d  } t
 | d d d  d k rd } n" t t
 | d d d   dJ } t t
 | d d d   dK } Wn" t k
 r} t d |   n X| d k r|  j d |  |  j d  | t @d k rN|  j d  n |  j d  | t @d k r{|  j d  n |  j d  |  j d |  |  j d |  |  j d |  |  j d  |  |  j d! |  |  j d" |  |  j d# |  n| d$ k rg  } t j   } t j | |  | _ | d  k	 r| d% k sY| d& k rs| t B} | j d'  q| d( k r| t @} | j d)  qn  | d  k	 r| d% k s| d& k r| t B} | j d*  q| d( k r| t @} | j d+  qn  | d  k	 s| d  k	 rBt j t |  t j d  | d <n  | d  k	 r| d& k rcd } n t
 |  } | d k  s| d k rt d,   n  t j t |  t j d  | d <| j d-  n  |	 d  k	 rN|	 d& k rd. }  n t
 |	  }  |  d k  s|  d/ k rt d0   n  t j t |   t j d	  | d	 <| j d1  n  | d  k	 r| d& k rod } n t
 |  } | d k  s| d2 k rt d3   n  t
 | dN  }! t j t |!  t j d
  | d
 <| j d4  n  | d  k	 r| d& k rd5 } n t
 |  } | d k  s*| d6 k r9t d7   n  | d k rNd }" n t
 | dQ  }" t j t |"  t j d  | d <| j d8  n  |
 d  k	 r=|
 d& k rd9 }
 n t
 |
  }
 |
 d k  s|
 d: k rt d;   n  |
 d k rd }# n t
 |
 dR  }# t j t |#  t j d  | d <| j d<  n  | d  k	 r| d& k r^d } n t
 |  } t j t |  t j d  | d <| j d=  n  | d  k	 rH| d& k rd9 } n t
 |  } | d k  s| d: k rt d;   n  | d k rd }$ n t
 | dS  }$ t j t |$  t j d  | d <| j d>  n  | d k ry| | k ryt d? | | f   n  t |  d k rt d@   n  | j |  | j dA  |  j dB j |   n t dC |   d  S(T   NR%  R  R  RG   R#  R   t   pwdPropertiest   pwdHistoryLengtht   minPwdLengtht	   minPwdAget	   maxPwdAget   lockoutDurationt   lockoutThresholdt   lockOutObservationWindowi   i    g    cAi<   i   l         s'   Could not retrieve password properties!RY  s%   Password informations for domain '%s'R   s   Password complexity: ons   Password complexity: offs   Store plaintext passwords: ons   Store plaintext passwords: offs   Password history length: %ds   Minimum password length: %ds   Minimum password age (days): %ds   Maximum password age (days): %ds#   Account lockout duration (mins): %ds(   Account lockout threshold (attempts): %ds&   Reset account lockout after (mins): %dt   setRt  Rv   s   Password complexity activated!Ru  s    Password complexity deactivated!s;   Plaintext password storage for changed passwords activated!s=   Plaintext password storage for changed passwords deactivated!s8   Password history length must be in the range of 0 to 24!s    Password history length changed!i   i   s8   Minimum password length must be in the range of 0 to 14!s    Minimum password length changed!i  s6   Minimum password age must be in the range of 0 to 998!s   Minimum password age changed!i+   i  s6   Maximum password age must be in the range of 0 to 999!s   Maximum password age changed!i   i s8   Maximum password age must be in the range of 0 to 99999!s!   Account lockout duration changed!s"   Account lockout threshold changed!s0   Duration to reset account lockout after changed!sI   Maximum password age (%d) must be greater than minimum password age (%d)!s7   You must specify at least one option to set. Try --helps!   All changes applied successfully!s   
s   Wrong argument '%s'!g    Ag   Ј Bg   8M%iBg    Ag   Ј Bg   8M%iBg    Ag    Ai  iQ g   8M%iBi  iQ g   8M%iBg    Ag    A(   RC   R  R   R   R\  R'  R*  R]  R   R^  R   t   absR   R   R`  R   R   R-  R7  R,  RD   Rb  R.  RS   R/  R0  R  (%   RF   RV  RU  t   min_pwd_aget   max_pwd_ageR   t
   complexityt   store_plaintextt   history_lengtht   min_pwd_lengtht   account_lockout_durationt   account_lockout_thresholdt   reset_account_lockout_afterR=   R<   R>   RG   R  R=  R\  Rb   t	   pwd_propst   pwd_hist_lent   cur_min_pwd_lent   cur_min_pwd_aget   cur_max_pwd_aget   cur_account_lockout_thresholdt   cur_account_lockout_durationt   cur_reset_account_lockout_afterR   Rm  Ro  t   min_pwd_lent   min_pwd_age_tickst   max_pwd_age_tickst   account_lockout_duration_tickst!   reset_account_lockout_after_ticks(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRI   o  s   	(	(	"&

										N(   RJ   RK   RL   RM   RN   RO   RQ   RP   RR   R   RS   RT   RU   RD   R   RI   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRs  C  sB   

											t   cmd_domain_classicupgradec           B   sZ  e  Z d  Z d Z i e j d 6e j d 6Z e d d d d d d	 d
 e d d d d d d	 d e d d d d d d	 d e d d	 d d d e d d	 d d d e d d d d d d d g d d d	 d d d e d d	 d  d d e d! d d d d" d d# d$ d% d& g d	 d' d d# g Z	 d( g Z
 d* d* d* d* e e d* d* d* d* e d)  Z RS(+   s   Upgrade from Samba classic (NT4-like) database to Samba AD DC database.

    Specify either a directory with all Samba classic DC databases and state files (with --dbdir) or
    the testparm utility from your classic installation (with --testparm).
    s"   %prog [options] <classic_smb_conf>R<   R>   s   --dbdirR@   Rf   Rg   R   R?   s+   Path to samba classic DC database directorys
   --testparmt   PATHs   Path to samba classic DC testparm utility from the previous installation.  This allows the default paths of the previous installation to be followeds   --targetdirsC   Path prefix where the new Samba 4.0 AD domain should be initialiseds   --quiets   Be quietRd   Re   s	   --verboses
   Be verboses   --use-xattrsRp   Rq   R   R   R   s   [yes|no|auto]s   Define if we should use the native fs capabilities or a tdb file for storing attributes likes ntacl, auto tries to make an inteligent guess based on the user rights and system capabilitiesRv   s   --use-ntvfss+   Use NTVFS for the fileserver (default = no)s   --dns-backends   NAMESERVER-BACKENDRr   Rs   Rt   Ru   s  The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), BIND9_FLATFILE uses bind9 text database to store zone information, BIND9_DLZ uses samba4 AD to store zone information, NONE skips the DNS setup entirely (this DC will not be a DNS server)R6   c         C   s  t  j j |  s% t d |   n  | rQ t  j j |  rQ t d |   n  | r} t  j j |  r} t d |   n  | r | r t d   n  |  j   } | r | j t j  n) | r | j t j  n | j t j	  | r
| r
| j
 d  d  } n  | j   } t j   } | j rA| j d | j  n  | d  k	 rrt  j j |  srt  j |  qrn  t } | d k rt } n | d k rb| j d	  rb| rt j d
 t  j j |   } n3 t j d
 t  j j t  j j | j d     } zN y) t j j | | j d d d  t } Wn t k
 rO| j d  n XWd  | j    Xn  i  } | r| | d <| | d <| | d <| d | d <n t! | | d  | d <t! | | d  | d <t! | | d  | d <t! | | d  | d <t" | d  d k r| d | d <n  x" | D] } | j | | |  q#W| j d  | j# |  t$ | |  } | j d  t% | | | d t&   d | d |
 d | d  S(   Ns   File %s does not exists"   Testparm utility %s does not exists   Directory %s does not exists'   Please specify either dbdir or testparms2   both dbdir and testparm specified, ignoring dbdir.R   R   R   s
   posix:eadbR   s   private dirs   O:S-1-5-32G:S-1-5-32s   S-1-5-32R   s   You are not root or your system do not support xattr, using tdb backend for attributes. If you intend to use this provision in production, rerun the script as root on a system supporting xattrs.s   state directorys   lock directorys
   /smbpasswds   smb passwd filei    s   Reading smb.conft   ProvisioningR  R   R   R   ('   R1   R   t   existsR   R   R   R   R  R   R   R   RD   RC   t   s3paramt   get_contextR   R~  R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R:   R   t   loadR   R   R   (   RF   R6   R   t   dbdirR5   R   R  R   R<   R>   R   R   R   RG   t   s3confR   t   tmpfilet   pathst   pt   samba3(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRI   ^  sv    			!3



N(   RJ   RK   RL   RM   RN   RO   RQ   RR   R   RT   RU   RD   R   RI   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR  8  s2   
$	t   cmd_domain_samba3upgradec           B   s   e  Z e j Z e Z RS(    (   RJ   RK   R  RL   R   t   hidden(    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    s   	t   LocalDCCredentialsOptionsc           B   s   e  Z d    Z RS(   c         C   s   t  j j |  | d d d  S(   Nt   special_names   local-dc(   RN   RP   t   __init__(   RF   t   parser(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    s    (   RJ   RK   R  (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    s   t   DomainTrustCommandc           B   ss  e  Z d  Z d   Z d Z d Z d Z d Z d Z d Z	 d Z
 d	 Z d
   Z d   Z d e f d     YZ d e f d     YZ d e f d     YZ d   Z d   Z d   Z d   Z e e d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e  d  Z! e  d   Z" d!   Z# d"   Z$ d#   Z% d$   Z& d%   Z' d&   Z( d( d( d'  Z* RS()   s   List domain trusts.c         C   sP   t  j |   d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _	 d  S(   N(
   R   R  RD   t   local_lpt   local_servert   local_binding_stringt   local_credst   remote_servert   remote_binding_stringt   remote_creds(   RF   (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    s    						i    i   i  l   %   l   4    l       l       l   .   c         C   s   t  j |  j S(   N(   t   ctypest   c_uint32t   value(   RF   t   v(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   _uint32  s    c         C   s7   | d  k r t S|  j | d  } | | k r3 t St S(   Ni    (   RD   R   R  R   (   RF   t   runtimet   valt   err32(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   check_runtime_error  s    t   LocalRuntimeErrorc           B   s   e  Z d    Z RS(   c         C   sJ   | j  | d  } | d } d | j | | | f } t j |  |  d  S(   Ni    i   s%   LOCAL_DC[%s]: %s - ERROR(0x%08X) - %s(   R  R  R   R  (   t   exception_selfRF   R  R`  R  t   errstrR>  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    s
    
(   RJ   RK   R  (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    s   t   RemoteRuntimeErrorc           B   s   e  Z d    Z RS(   c         C   sJ   | j  | d  } | d } d | j | | | f } t j |  |  d  S(   Ni    i   s&   REMOTE_DC[%s]: %s - ERROR(0x%08X) - %s(   R  R  R   R  (   R  RF   R  R`  R  R  R>  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    s
    
(   RJ   RK   R  (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    s   t   LocalLdbErrorc           B   s   e  Z d    Z RS(   c         C   sA   | d } | d } d | j  | | | f } t j |  |  d  S(   Ni    i   s!   LOCAL_DC[%s]: %s - ERROR(%d) - %s(   R  R   R  (   R  RF   t	   ldb_errorR`  t   errvalR  R>  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    s
    

(   RJ   RK   R  (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    s   c   
      C   s   |  j  d  k	 r |  j  S| j   } | j } | d  k r | j   } | d k rb t d |   n  | j d  } d } d } | d 7} d  } d  }	 n% d } d } d | } | j |  }	 | |  _ | |  _  d	 | | | f |  _	 | |  _
 |	 |  _ |  j  S(
   Nt   ROLE_ACTIVE_DIRECTORY_DCs   Invalid server_role %ss   netbios namet   ncalrpcR   s   ,auth_type=ncalrpc_as_systemt   ncacn_nps	   ldap://%ss	   %s:%s[%s](   R  RD   RC   R  R   R   R   R  R  R  t   local_ldap_urlR  (
   RF   R<   t   localdcoptsRG   R  R   t   local_transportt   local_binding_optionsR  R  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   setup_local_server  s0    	
	
				c         C   s   t  j |  j |  j |  j  S(   N(   R   t   lsarpcR  R  R  (   RF   (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   new_local_lsa_connection   s    c         C   s   t  j  |  j |  j |  j  S(   N(   R   R  R  R  (   RF   (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   new_local_netlogon_connection#  s    c      	   C   s+   t  d |  j d t   d |  j d |  j  S(   NR%  R  R  RG   (   R   R  R   R  R  (   RF   (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   new_local_ldap_connection&  s    		c         C   s(  | r | s t   n  |  j d  k	 r+ |  j Sd | |  _ |  j d  k	 sM t   | j |  j  } | j } d } yv t | |  j d | } t j	 t j
 B}	 | r |	 t j O}	 n  | r |	 t j O}	 n  | j d |	 d | d |  }
 Wn! t k
 rt d |   n Xi d t j 6d	 t j 6d
 t j	 6d t j
 6d t j 6d t j 6d t j 6d t j 6d t j 6d t j 6d t j 6d t j 6d t j 6d t j 6d t j 6d t j 6d t j 6} |  j | |
 j d t } |  j  j! d |
 j" |
 j# | f  |
 j# |  _ d |  j | f |  _$ | |  _% |  j S(   Ns   __unknown__remote_server__.%sR   R  t   flagsR   RW   s-   Failed to find a writeable DC for domain '%s't   PDCt   GCt   LDAPt   DSt   KDCt   TIMESERVt   CLOSESTt   WRITABLEt   GOOD_TIMESERVt   NDNCt   SELECT_SECRET_DOMAIN_6t   FULL_SECRET_DOMAIN_6t   ADS_WEB_SERVICEt   DS_8t   HAS_DNS_NAMEt   IS_DEFAULT_NCt   FOREST_ROOTt
   names_onlys,   RemoteDC Netbios[%s] DNS[%s] ServerType[%s]
s   ncacn_np:%s[%s](&   R^  R  RD   R  R  R  R  R   R   t   NBT_SERVER_LDAPt   NBT_SERVER_DSt   NBT_SERVER_WRITABLEt   NBT_SERVER_PDCt   finddcR   R   t   NBT_SERVER_GCt   NBT_SERVER_KDCt   NBT_SERVER_TIMESERVt   NBT_SERVER_CLOSESTt   NBT_SERVER_GOOD_TIMESERVt   NBT_SERVER_NDNCt!   NBT_SERVER_SELECT_SECRET_DOMAIN_6t   NBT_SERVER_FULL_SECRET_DOMAIN_6t   NBT_SERVER_ADS_WEB_SERVICEt   NBT_SERVER_DS_8t   NBT_SERVER_HAS_DNS_NAMEt   NBT_SERVER_IS_DEFAULT_NCt   NBT_SERVER_FOREST_ROOTt   generic_bitmap_to_stringt   server_typeR   RY   RZ   R_   R^   R  R  (   RF   R=   R   t   require_pdct   require_writableR  R  t   remote_binding_optionst
   remote_nett   remote_flagst   remote_infot   flag_mapt   server_type_string(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   setup_remote_server,  s^    	"















		c         C   s   t  j |  j |  j |  j  S(   N(   R   R  R  R  R  (   RF   (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   new_remote_lsa_connectioni  s    c         C   s   t  j  |  j |  j |  j  S(   N(   R   R  R  R  (   RF   (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   new_remote_netlogon_connectionl  s    c         C   sX   t  j   } t  j   | _ | j d j d  | |  } | j | t  j  } | | f S(   NR   s   utf-8(   R   t   ObjectAttributet   QosInfot   sec_qost   OpenPolicy2t   decodet   QueryInfoPolicy2t   LSA_POLICY_INFO_DNS(   RF   t   connt   policy_accesst
   objectAttrt   policyR   (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   get_lsa_infoo  s    c         C   s(   | j  | d  d d  d  d  t j  } | S(   Ni    (   t   netr_DsRGetDCNameEx2RD   R   t   DS_RETURN_DNS_NAME(   RF   R  R  R   (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   get_netlogon_dc_infoz  s    	c         C   s    | j  t j k r | j S| j S(   N(   t
   trust_typeR   t   LSA_TRUST_TYPE_DOWNLEVELR  t   dns_name(   RF   t   t(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   netr_DomainTrust_to_name  s    c         C   s   d  } d  } xH | D]@ } | j t j @r | } | j t j @sO | | j } n  Pq q W| j t j @r | | k rw d S| j t j @r d S| | j } | | k r d Sd S| j t j	 @r d Sd S(   Nt   Parentt   TreeRoott   Childt   Shortcutt   Forestt   External(
   RD   t   trust_flagsR   t   NETR_TRUST_FLAG_PRIMARYt   NETR_TRUST_FLAG_TREEROOTt   parent_indext   NETR_TRUST_FLAG_IN_FORESTt   trust_attributesR   t%   LSA_TRUST_ATTRIBUTE_FOREST_TRANSITIVE(   RF   t   aR  t   primaryt   primary_parentt   _tR5  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   netr_DomainTrust_to_type  s(    c         C   s@   | j  t j @r d S| j t j @r( d S| j t j @r< d Sd S(   Nt   Yest   No(   R  R   R  R  R   t"   LSA_TRUST_ATTRIBUTE_NON_TRANSITIVER  (   RF   R  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   netr_DomainTrust_to_transitive  s    c         C   sP   | j  t j @r$ | j  t j @r$ d S| j  t j @r8 d S| j  t j @rL d Sd S(   Nt   BOTHt   INCOMINGt   OUTGOINGt   INVALID(   R  R   t   NETR_TRUST_FLAG_INBOUNDt   NETR_TRUST_FLAG_OUTBOUND(   RF   R  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   netr_DomainTrust_to_direction  s    c         C   sO   y | | } Wn* t  k
 r: |  j |  } d | } n Xd | | f } | S(   Ns   __unknown__%08X__s	   0x%x (%s)(   R_  R  (   RF   t   e_dictR  R  t   wt   v32R0   (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   generic_enum_to_string  s    c   
      C   s   g  } | } xF t  | j    D]2 } | | @s5 q n  | | M} | | | g 7} q W| d k r |  j |  } | d | g 7} n  d j |  } | r | Sd | | f }	 |	 S(   Ni    s   __unknown_%08X__t   ,s	   0x%x (%s)(   t   sortedt   keysR  R  (
   RF   t   b_dictR  R  RP  t   ct   bt   c32R1  R0   (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    s    
c         C   s>   i d t  j 6d t  j 6d t  j 6d t  j 6} |  j | |  S(   Nt	   DOWNLEVELt   UPLEVELt   MITt   DCE(   R   R  t   LSA_TRUST_TYPE_UPLEVELt   LSA_TRUST_TYPE_MITt   LSA_TRUST_TYPE_DCER3  (   RF   R  t   types(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   trustType_string  s    


c         C   s;   i d t  j t  j B6d t  j 6d t  j 6} |  j | |  S(   NR)  t   INBOUNDt   OUTBOUND(   R   t   LSA_TRUST_DIRECTION_INBOUNDt   LSA_TRUST_DIRECTION_OUTBOUNDR3  (   RF   R  t
   directions(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   trustDirection_string  s
    
c         C   sf   i d t  j 6d t  j 6d t  j 6d t  j 6d t  j 6d t  j 6d t  j 6d t  j 6} |  j	 | |  S(	   Nt   NON_TRANSITIVEt   UPLEVEL_ONLYt   QUARANTINED_DOMAINt   FOREST_TRANSITIVEt   CROSS_ORGANIZATIONt   WITHIN_FORESTt   TREAT_AS_EXTERNALt   USES_RC4_ENCRYPTION(
   R   R'  t    LSA_TRUST_ATTRIBUTE_UPLEVEL_ONLYt&   LSA_TRUST_ATTRIBUTE_QUARANTINED_DOMAINR  t&   LSA_TRUST_ATTRIBUTE_CROSS_ORGANIZATIONt!   LSA_TRUST_ATTRIBUTE_WITHIN_FORESTt%   LSA_TRUST_ATTRIBUTE_TREAT_AS_EXTERNALt'   LSA_TRUST_ATTRIBUTE_USES_RC4_ENCRYPTIONR  (   RF   R  t
   attributes(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   trustAttributes_string  s    






c         C   sp   i	 d t  j 6d t  j 6d t  j 6d t  j 6d t  j 6d t  j 6d t  j 6d t  j 6d	 t  j	 6} |  j
 | |  S(
   Nt   DES_CBC_CRCt   DES_CBC_MD5t   RC4_HMAC_MD5t   AES128_CTS_HMAC_SHA1_96t   AES256_CTS_HMAC_SHA1_96t   FAST_SUPPORTEDt   COMPOUND_IDENTITY_SUPPORTEDt   CLAIMS_SUPPORTEDt!   RESOURCE_SID_COMPRESSION_DISABLED(   R   t   KERB_ENCTYPE_DES_CBC_CRCt   KERB_ENCTYPE_DES_CBC_MD5t   KERB_ENCTYPE_RC4_HMAC_MD5t$   KERB_ENCTYPE_AES128_CTS_HMAC_SHA1_96t$   KERB_ENCTYPE_AES256_CTS_HMAC_SHA1_96t   KERB_ENCTYPE_FAST_SUPPORTEDt(   KERB_ENCTYPE_COMPOUND_IDENTITY_SUPPORTEDt   KERB_ENCTYPE_CLAIMS_SUPPORTEDt.   KERB_ENCTYPE_RESOURCE_SID_COMPRESSION_DISABLEDR  (   RF   R  t   enctypes(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   kerb_EncTypes_string  s    







c         C   sN   | d k r d Si d t  j 6d t  j 6d t  j 6} d |  j | | d t S(   Ni    s   Status[Enabled]s   Disabled-Newt   Disableds   Disabled-Conflictings
   Status[%s]R  (   R   t   LSA_TLN_DISABLED_NEWt   LSA_TLN_DISABLED_ADMINt   LSA_TLN_DISABLED_CONFLICTR  R   (   RF   t   e_flagsR  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   entry_tln_status  s    

c         C   sX   | d k r d Si d t  j 6d t  j 6d t  j 6d t  j 6} d |  j | | d t S(	   Ni    s   Status[Enabled]s   Disabled-SIDs   Disabled-SID-Conflictings   Disabled-NBs   Disabled-NB-Conflictings
   Status[%s]R  (   R   t   LSA_SID_DISABLED_ADMINt   LSA_SID_DISABLED_CONFLICTt   LSA_NB_DISABLED_ADMINt   LSA_NB_DISABLED_CONFLICTR  R   (   RF   Rr  R  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   entry_dom_status  s    


c         C   s  | d  k	 r d | } n d } |  j j d t | j  | f  xVt d t | j   D]<} | j | } | j } d } | d  k	 r xB | j D]4 }	 |	 j | k r q n  |	 j } d |	 j j	 } q Wn  | j
 }
 | j t j k r|  j j d |  j |  |
 j	 | f  q[ | j t j k rG|  j j d d |
 j	 f  q[ | j t j k r[ |  j j d |  j |  |
 j j	 |
 j j	 |
 j | f  q[ q[ Wd  S(	   Ns    TDO[%s]R   s   Namespaces[%d]%s:
i    s    Collision[%s]s   TLN: %-32s DNS[*.%s]%s
s   TLN_EX: %-29s DNS[*.%s]
s)   DOM: %-32s DNS[%s] Netbios[%s] SID[%s]%s
(   RD   RY   RZ   R   t   entriest   xrangeR  t   indexR   Rf   t   forest_trust_dataR@   R   t   LSA_FOREST_TRUST_TOP_LEVEL_NAMERs  t"   LSA_FOREST_TRUST_TOP_LEVEL_NAME_EXt   LSA_FOREST_TRUST_DOMAIN_INFORx  t   dns_domain_namet   netbios_domain_nameR   (   RF   t   ftit   tlnt
   collisionst
   tln_stringRK  R   R  t   collision_stringR8  t   d(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   write_forest_trust_info  s<    					N(+   RJ   RK   RL   R  t   WERR_OKt   WERR_INVALID_FUNCTIONt   WERR_NERR_ACFNOTLOADEDt   NT_STATUS_NOT_FOUNDt   NT_STATUS_OBJECT_NAME_NOT_FOUNDt   NT_STATUS_INVALID_PARAMETERt   NT_STATUS_INVALID_INFO_CLASSt"   NT_STATUS_RPC_PROCNUM_OUT_OF_RANGER  R  R   R  R  R  R  R  R  R  R   R  R  R  R
  R  R  R$  R(  R/  R   R3  R  RC  RI  RY  Rm  Rs  Rx  RD   R  (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    sL   			
				;								
								t   cmd_domain_trust_listc           B   sM   e  Z d  Z d Z i e j d 6e j d 6e d 6Z g  Z	 d d d d  Z RS(   s   List domain trusts.s   %prog [options]R<   R>   R  c   
   	   C   sU  |  j  | |  } y |  j   } Wn( t k
 rL } |  j |  | d   n Xy' | j | t j t j Bt j B } WnS t k
 r } |  j	 | |  j
  r t d |  j   n  |  j |  | d   n X| j } x{ | D]s }	 |	 j t j @r q n  |  j j d d |  j | |	  d |  j |	  d |  j |	  d |  j |	  f  q Wd  S(	   Ns!   failed to connect netlogon servers:   LOCAL_DC[%s]: netr_DsrEnumerateDomainTrusts not supported.s$   netr_DsrEnumerateDomainTrusts faileds   %-14s %-15s %-19s %s
s   Type[%s]s   Transitive[%s]s   Direction[%s]s   Name[%s](   R  R  RX   R  t   netr_DsrEnumerateDomainTrustsR   R  R.  R-  R  R  R   R  t   arrayR  R  RY   RZ   R$  R(  R/  R  (
   RF   R<   R>   R  R  t   local_netlogont   errort   local_netlogon_trustsR   R  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRI   R  s0    		N(   RJ   RK   RL   RM   RN   RO   RQ   R  RR   RT   RD   RI   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR  D  s   


t   cmd_domain_trust_showc           B   sV   e  Z d  Z d Z i e j d 6e j d 6e d 6Z g  Z	 d g Z
 d d d d  Z RS(   s   Show trusted domain details.s   %prog NAME [options]R<   R>   R  R   c         C   s9  |  j  | |  } y |  j   } Wn( t k
 rL } |  j |  | d   n Xy% t j } |  j | |  \ }	 }
 Wn( t k
 r } |  j |  | d   n X|  j j d |
 j	 j
 |
 j j
 |
 j f  t j   } | | _
 y. | j |	 | t j  } | j } | j } WnP t k
 r^} |  j | |  j  rFt d |   n  |  j |  | d   n Xy | j |	 | t j  } Wn t k
 r} |  j | |  j  rd  } n  |  j | |  j  rd  } n  | d  k	 r|  j |  | d   n  t j   } d | _ n Xy5 d  } | j t j @r:| j |	 | t j  } n  Wn t k
 r} |  j | |  j  rkd  } n  |  j | |  j   rd  } n  | d  k	 r|  j |  | d   n  t j!   } d | _" g  | _# n X|  j j d	  |  j j d
 | j$ j
  | j$ j
 | j% j
 k r.|  j j d | j% j
  n  |  j j d | j  |  j j d |  j& | j'   |  j j d |  j( | j)   |  j j d |  j* | j   t+ j, | j  j- } t+ j. | j  j- } |  j j d | | f  |  j j d |  j/ | j   | j t j @r5|  j0 | d | j% j
 n  d  S(   Ns   failed to connect lsa servers#   failed to query LSA_POLICY_INFO_DNSs(   LocalDomain Netbios[%s] DNS[%s] SID[%s]
s4   trusted domain object does not exist for domain [%s]s.   QueryTrustedDomainInfoByName(FULL_INFO) faileds?   QueryTrustedDomainInfoByName(SUPPORTED_ENCRYPTION_TYPES) failedi    s&   lsaRQueryForestTrustInformation faileds   TrusteDomain:

s   NetbiosName:    %s
s   DnsName:        %s
s   SID:            %s
s   Type:           %s
s   Direction:      %s
s   Attributes:     %s
s   PosixOffset:    0x%08X (%d)
s   kerb_EncTypes:  %s
R  (1   R  R  RX   R  R   t!   LSA_POLICY_VIEW_LOCAL_INFORMATIONR
  RY   RZ   R   Rf   R\   R  t   Stringt   QueryTrustedDomainInfoByNamet!   LSA_TRUSTED_DOMAIN_INFO_FULL_INFOt   info_ext   posix_offsetR  R  R   t-   LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPESR  RD   R  t    TrustDomainInfoSupportedEncTypest	   enc_typesR  R  t   lsaRQueryForestTrustInformationR  R  R  t   ForestTrustInformationt   countRy  R  R]   RC  R  RI  t   trust_directionRY  R  R  R  t   c_int32Rm  R  (   RF   R   R<   R>   R  R  t	   local_lsaR  t   local_policy_accesst   local_policyt   local_lsa_infot	   lsaStringt   local_tdo_fullt   local_tdo_infot   local_tdo_posixt   local_tdo_enctypest   local_tdo_forestt   posix_offset_u32t   posix_offset_i32(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRI     s    													    N(   RJ   RK   RL   RM   RN   RO   RQ   R  RR   RT   RU   RD   RI   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR  q  s   


	t   cmd_domain_trust_createc           B   s  e  Z d  Z d Z i e j d 6e j d 6e j d 6e d 6Z	 e
 d d d d	 d
 d d d g d d d d d d e
 d d d d	 d d d d d g d d d d d d e
 d d d d	 d d d d g d d d d d d e
 d d  d! d d" d d# d e e
 d$ d d d	 d% d d& d' d9 g d d( d d) d d9 e
 d* d  d! d d+ d d, d e e
 d- d  d! d d. d d/ d e e
 d0 d  d1 d d2 d d3 d e e
 d4 d  d1 d d5 d d6 d e g	 Z d7 g Z d9 d9 d9 d9 d9 d9 d9 e d9 e e e e d8  Z RS(:   s    Create a domain or forest trust.s   %prog DOMAIN [options]R<   R>   R=   R  s   --typeR@   Rp   Rg   t   TYPERq   t   externalR[   R?   s.   The type of the trust: 'external' or 'forest'.RT  R  Rv   s   --directiont	   DIRECTIONt   incomingt   outgoingt   boths6   The trust direction: 'incoming', 'outgoing' or 'both'.R  s   --create-locationt   LOCATIONt   locals=   Where to create the trusted domain object: 'local' or 'both'.t   create_locations   --cross-organisationRd   Re   s=   The related domains does not belong to the same organisation.t   cross_organisations   --quarantineds   yes|noR   R   s   Special SID filtering rules are applied to the trust. With --type=external the default is yes. With --type=forest the default is no.t   quarantined_args   --not-transitives#   The forest trust is not transitive.t   not_transitives   --treat-as-externals'   The treat the forest trust as external.t   treat_as_externals   --no-aes-keyst   store_falses!   The trust uses aes kerberos keys.t   use_aes_keyss   --skip-validations   Skip validation of the trust.t   validateR   c   C         s  t  j   } t } |
 d  k r6 | d k rK t } qK n |
 d k rK t } n  | d k r | rl t d   n  | r t d   q n  d  } | r t  j   } t j | _	 | j	 t j
 O_	 n  t  j } | t  j O} | t  j O} t  j   } t  j | _ d | _ | d k r4| j t  j O_ | j t  j O_ nB | d k rU| j t  j O_ n! | d	 k rv| j t  j O_ n  d | _ |	 r| j t  j O_ n  | r| j t  j O_ n  | d k r| j t  j O_ n  | r| j t  j O_ n  | r| j t  j O_ n    f d
   } d  } d  } t  j } | d k r| j t  j @rp| d  } t | j d   } n  | j t  j @r| d  } t | j d   } n  d  } nt d  } | j t  j @r| d d | } n  | j t  j @r| d d | } n  | t  j O} | t  j O} t  j   } t  j | _ d | _ | d k rq| j t  j O_ | j t  j O_ nB | d k r| j t  j O_ n! | d	 k r| j t  j O_ n  d | _ |	 r| j t  j O_ n  | r| j t  j O_ n  | d k r| j t  j O_ n  | r.| j t  j O_ n  | rI| j t  j O_ n    j | |  } y   j   } Wn( t k
 r}   j   | d   n Xy   j  | |  \ } }  Wn( t k
 r}   j   | d   n X  j! j" d |  j# j$ |  j% j$ |  j& f  y   j' | |  }! Wn( t k
 rI}   j(   | d   n Xy   j)   }" Wn( t k
 r}   j(   | d   n Xy   j  |" |  \ }# }$ Wn( t k
 r}   j(   | d   n X  j! j" d |$ j# j$ |$ j% j$ |$ j& f  |$ j% j$ | j* _$ |$ j# j$ | j+ _$ |$ j& | _& | ra|  j% j$ | j* _$ |  j# j$ | j+ _$ |  j& | _& n  y> | j* j$ | _$ | j, | | t  j-  }% t d | j$   WnG t k
 r}   j. |   j/  s  j   | d | j$   qn Xy> | j+ j$ | _$ | j, | | t  j-  }& t d | j$   WnG t k
 rp}   j. |   j/  sq  j   | d | j$   qqn X| ry> | j* j$ | _$ |" j, |# | t  j-  }' t d | j$   WnG t k
 r}   j. |   j/  s  j(   | d | j$   qn Xy> | j+ j$ | _$ |" j, |# | t  j-  }( t d | j$   Wqt k
 r}   j. |   j/  s  j(   | d | j$   qqXn  y   j0   }) Wn( t k
 r}   j   | d   n Xy   j1 |) |  }* Wn( t k
 r	}   j   | d   n X| r	y   j2   }+ Wn( t k
 rF	}   j(   | d   n Xy   j1 |+ |!  }, Wq	t k
 r	}   j(   | d   q	Xn  d   }- d  d  d  }. t3 j4   }/ |- | |/  }0 |- | |/  }1 d  }2 d  }3 |. | j5 d |0 d	 |1 }4 | r
|. |" j5 d |1 d	 |0 }5 n  y1| r
  j! j" d  i d d 6d  d! 6}6 |" j6 |# | |5 t  j7  }3   j! j" d"  | r
  j! j" d#  i d d 6d$ d! 6}6 |" j8 |3 t  j9 |  q
n    j! j" d%  i d d 6d  d! 6}6 | j6 | | |4 t  j7  }2   j! j" d&  | rH  j! j" d'  i d d 6d$ d! 6}6 | j8 |2 t  j9 |  n  Wn t k
 r%}   j! j" d( |6 d! |6 d f  |3 r  j! j" d)  |" j: |3  d  }3 n  |2 r  j! j" d*  | j: |2  d  }2 n  |6 d d k r  j(   | d+ |6 d!   n    j   | d+ |6 d!   n X| rn| j t  j @r  j! j" d,  y% |) j; |* j< |$ j% j$ t= j>  }7 Wn( t k
 r}   j   | d-   n Xy% | j? | |$ j% t  j@ |7 d  }8 Wn( t k
 r}   j   | d.   n X  jA |7 d/ |$ j% j$ d0 |8 | r  j! j" d1  y% |+ j; |, j< |  j% j$ t= j>  }9 Wn( t k
 rp}   j(   | d-   n Xy% |" j? |# |  j% t  j@ |9 d  }: Wn( t k
 r}   j(   | d.   n X  jA |9 d/ |  j% j$ d0 |: qn  | j t  j @r$  j! j" d2  y( |) jB |* j< t= jC d3 |$ j% j$  }; Wn( t k
 rX}   j   | d4   n X  jD |; jE d  }<   jD |; jF d  }= |; jG t= jH @rd5 |; jI |; jF d6 |; jE d6 f }> n$ d7 |; jI |; jF d6 |; jE d6 f }> |<   jJ k s|=   jJ k rt |>   q$  j! j" d8 |>  n  | rn| j t  j @rk  j! j" d9  y( |+ jB |, j< t= jC d3 |  j% j$  }? Wn( t k
 r}   j(   | d4   n X  jD |? jE d  }@   jD |? jF d  }A |? jG t= jH @r d: |? jI |? jF d6 |? jE d6 f }B n$ d; |? jI |? jF d6 |? jE d6 f }B |@   jJ k sB|A   jJ k rQt |B   qh  j! j" d8 |B  qkqnn  |3 d  k	 ry |" jK |3  Wn t k
 r} n Xd  }3 n  |2 d  k	 ry | jK |2  Wn t k
 r} n Xd  }2 n    j! j" d<  d  S(=   NR  R   R[   s'   --not-transitive requires --type=forests*   --treat-as-external requires --type=foresti    R  R  R  c            sx   d  } xk t rs | d  k	 r+ | d k	 r+ | St d |   } t d |   } | | k s	 d  }   j j d  q	 q	 Wd  S(   NR   s   New %s Password: s   Retype %s Password: s   Sorry, passwords do not match.
(   RD   R   R    RY   RZ   (   R   t   passwordt   passwordverify(   RF   (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   get_passwordE  s    	R  s   Incoming Trusts	   utf-16-les   Outgoing Trustc         S   s   d g |  } t  j |  d |  d  } | s@ t | j d   SxY t t |   D]E } t |  | k r t | |  | | <qS t j d d  | | <qS W| S(   Ni    i   s	   utf-16-lei   (	   R   t   generate_random_passwordR    t   encodet   rangeR   t   ordt   randomt   randint(   t   lengthR  t   secrett   pw1RK  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   random_trust_secretg  s    i   R  s   failed to connect lsa servers#   failed to query LSA_POLICY_INFO_DNSs(   LocalDomain Netbios[%s] DNS[%s] SID[%s]
s   failed to locate remote servers)   RemoteDomain Netbios[%s] DNS[%s] SID[%s]
s   TrustedDomain %s already exist's2   QueryTrustedDomainInfoByName(%s, FULL_INFO) faileds!   failed to connect netlogon servers   failed to get netlogon dc infoc         S   s   |  d  k r% t j   } d | _ | St j   } t |   | _ |  | _ t j   } t	 j
 |  | _ t j | _ | | _ t j   } d | _ | g | _ t j   } d | _ | | _ | S(   Ni    i   (   RD   R   t   trustAuthInOutBlobR  t   AuthInfoClearR   t   sizeR  t   AuthenticationInformationR   t   unix2nttimet   LastUpdateTimeR   t   TRUST_AUTH_TYPE_CLEARt   AuthTypet   AuthInfot   AuthenticationInformationArrayR  t   current(   R  t   update_timet   blobt   clearR   R  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   generate_AuthInOutBlob	  s$    						c   
      S   s   d g d } x0 t  t |   D] } t j d d  | | <q  Wt j   } | | _ | | _ | | _ t	 |  } t
 |  |  } t j   } t |  | _ t |  | _ t j   }	 | |	 _ |	 S(   Ni    i   i   (   R  R   R  R  R   t   trustDomainPasswordst
   confounderR  R  R	   R   R   t	   DATA_BUF2R  R    t   datat   TrustDomainInfoAuthInfoInternalt	   auth_blob(
   t   session_keyR  R  R  RK  t	   trustpasst   trustpass_blobt   encrypted_trustpassR  t	   auth_info(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   generate_AuthInfoInternal%	  s    				s   Creating remote TDO.
t   remotet   locationt   CreateTrustedDomainEx2R   s   Remote TDO created.
s2   Setting supported encryption types on remote TDO.
t   SetInformationTrustedDomains   Creating local TDO.
s   Local TDO created
s1   Setting supported encryption types on local TDO.
s$   Error: %s failed %sly - cleaning up
s   Deleting remote TDO.
s   Deleting local TDO.
s   %ss(   Setup local forest trust information...
s*   netr_DsRGetForestTrustInformation() faileds&   lsaRSetForestTrustInformation() failedR  R  s)   Setup remote forest trust information...
s   Validating outgoing trust...
i   s!   NETLOGON_CONTROL_TC_VERIFY failedsG   LocalValidation: DC[%s] CONNECTION[%s] TRUST[%s] VERIFY_STATUS_RETURNEDi   s0   LocalValidation: DC[%s] CONNECTION[%s] TRUST[%s]s   OK: %s
s   Validating incoming trust...
sH   RemoteValidation: DC[%s] CONNECTION[%s] TRUST[%s] VERIFY_STATUS_RETURNEDs1   RemoteValidation: DC[%s] CONNECTION[%s] TRUST[%s]s	   Success.
(L   R   R  R   RD   R   R   R  R   Rf  R  Rg  R  t   LSA_POLICY_TRUST_ADMINt   LSA_POLICY_CREATE_SECRETt   TrustDomainInfoInfoExR?  R  R  RF  RG  R  RT  RS  R  R'  RV  R    R  R  R  RX   R  R
  RY   RZ   R   Rf   R\   R  R  R  R  R]   R  R  R  R  R  R  R  R  R   t   current_unix_timeR  R  t   LSA_TRUSTED_DOMAIN_ALL_ACCESSR  R  t   DeleteObjectt!   netr_DsRGetForestTrustInformationt   dc_uncR   t   DS_GFTI_UPDATE_TDOt   lsaRSetForestTrustInformationR  R  t   netr_LogonControl2Ext   NETLOGON_CONTROL_TC_VERIFYR  t   pdc_connection_statust   tc_connection_statusR  t   NETLOGON_VERIFY_STATUS_RETURNEDt   trusted_dc_nameR  t   Close(C   RF   R   R<   R  R=   R>   R  R  R  R  R  R  R  R  R  R  t   quarantinedR  R  t   local_trust_infoR  t   incoming_secrett   outgoing_secrett   remote_policy_accesst   incoming_passwordt   outgoing_passwordt   remote_trust_infoR  R  R  R  R  R  R  t
   remote_lsat   remote_policyt   remote_lsa_infot   local_old_netbiost   local_old_dnst   remote_old_netbiost   remote_old_dnsR  t   local_netlogon_infot   remote_netlogont   remote_netlogon_infoR  R  R  t   incoming_blobt   outgoing_blobt   local_tdo_handlet   remote_tdo_handlet   local_auth_infot   remote_auth_infot   current_requestt   local_forest_infot   local_forest_collisiont   remote_forest_infot   remote_forest_collisiont   local_trust_verifyt   local_trust_statust   local_conn_statust   local_validationt   remote_trust_verifyt   remote_trust_statust   remote_conn_statust   remote_validation(    (   RF   s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRI     s   																												



		N(   RJ   RK   RL   RM   RN   RO   RQ   RP   R  RR   R   R   RD   R   RT   RU   RI   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR    sj   



		t   cmd_domain_trust_deletec           B   s   e  Z d  Z d Z i e j d 6e j d 6e j d 6e d 6Z	 e
 d d d d	 d
 d d d g d d d d d d g Z d g Z d d d d d d  Z RS(   s   Delete a domain trust.s   %prog DOMAIN [options]R<   R>   R=   R  s   --delete-locationR@   Rp   Rg   R  Rq   R  R  R?   s=   Where to delete the trusted domain object: 'local' or 'both'.RT  t   delete_locationRv   R   c      
   C   s  t  j } | t  j O} | t  j O} | d k r8 d  } n# t  j } | t  j O} | t  j O} |  j | |  }	 y |  j   }
 Wn( t k
 r } |  j |  | d   n Xy |  j	 |
 |  \ } } Wn( t k
 r } |  j |  | d   n X|  j
 j d | j j | j j | j f  d  } d  } d  } d  } t  j   } y% | | _ |
 j | | t  j  } WnP t k
 r} |  j | |  j  rt d |   n  |  j |  | d   n X| d  k	 ry |  j | |  } Wn( t k
 r} |  j |  | d   n Xy |  j   } Wn( t k
 r>} |  j |  | d   n Xy |  j	 | |  \ } } Wn( t k
 r} |  j |  | d   n X|  j
 j d | j j | j j | j f  | j | j k s| j j | j j k s| j j | j j k rt d | j j | j j | j f   n  y+ | j j | _ | j | | t  j  } WnG t k
 r} |  j | |  j  s|  j |  | d	 | j   qn X| d  k	 r| j | j k s| j j | j j k s| j j | j j k rt d
 | j j | j j | j f   qqn  | d  k	 ry+ | j j | _ |
 j | | t j  } Wn/ t k
 r{} |  j |  | d | j   n X|
 j |  d  } n  | d  k	 ry+ | j j | _ | j | | t j  } Wqt k
 r} |  j |  | d | j   qXn  | d  k	 rmy' | j |  d  } |  j
 j d  Wqmt k
 ri} |  j
 j d |  j |  | d   qmXn  | d  k	 ry' |
 j |  d  } |  j
 j d  Wqt k
 r} |  j
 j d |  j |  | d   qXn  d  S(   NR  s   failed to connect lsa servers#   failed to query LSA_POLICY_INFO_DNSs(   LocalDomain Netbios[%s] DNS[%s] SID[%s]
s$   Failed to find trust for domain '%s's   failed to locate remote servers)   RemoteDomain Netbios[%s] DNS[%s] SID[%s]
s2   LocalTDO inconsistend: Netbios[%s] DNS[%s] SID[%s]s    QueryTrustedDomainInfoByName(%s)s3   RemoteTDO inconsistend: Netbios[%s] DNS[%s] SID[%s]s   OpenTrustedDomainByName(%s)s   RemoteTDO deleted.
s   %s
s   DeleteObject() faileds   LocalTDO deleted.
(   R   R  R  R  RD   R  R  RX   R  R
  RY   RZ   R   Rf   R\   R  R  R  t   LSA_TRUSTED_DOMAIN_INFO_INFO_EXR  R  R   R  R  R  R  R]   t   OpenTrustedDomainByNameR   t   SEC_STD_DELETER  (   RF   R   R<   R  R=   R>   R&  R  R  R  R  R  R  R  R  R  t   remote_tdo_infoR  R  R  R  R	  R
  (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRI   
  s    																	**N(   RJ   RK   RL   RM   RN   RO   RQ   RP   R  RR   R   RT   RU   RD   RI   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR%  	  s   



	t   cmd_domain_trust_validatec           B   s   e  Z d  Z d Z i e j d 6e j d 6e j d 6e d 6Z	 e
 d d d d	 d
 d d d g d d d d d d g Z d g Z d d d d d d  Z RS(   s   Validate a domain trust.s   %prog DOMAIN [options]R<   R>   R=   R  s   --validate-locationR@   Rp   Rg   R  Rq   R  R  R?   s?   Where to validate the trusted domain object: 'local' or 'both'.RT  t   validate_locationRv   R   c          C   s'  t  j } |  j | |  } y |  j   }	 Wn( t k
 rU }
 |  j |  |
 d   n Xy |  j |	 |  \ } } Wn( t k
 r }
 |  j |  |
 d   n X|  j j d | j	 j
 | j j
 | j f  y1 t  j   } | | _
 |	 j | | t  j  } WnP t k
 rL}
 |  j |
 |  j  r4t d |   n  |  j |  |
 d   n X|  j j d | j j
 | j j
 | j f  y |  j   } Wn( t k
 r}
 |  j |  |
 d   n Xy% | j | t j d | j j
  } Wn( t k
 r}
 |  j |  |
 d	   n X|  j | j d
  } |  j | j d
  } | j t j @rgd | j | j d | j d f } n$ d | j | j d | j d f } | |  j k s| |  j k rt |   n |  j j d |  yJ | j j  d d  } d | j j
 | f } | j | t j! d |  } Wn( t k
 r@}
 |  j |  |
 d   n X|  j | j d
  } d | j | j d f } | |  j k rt |   n |  j j d |  | d k r#y |  j" | | d t# } Wn( t k
 r}
 |  j$ |  |
 d   n Xy |  j%   } Wn( t k
 r0}
 |  j$ |  |
 d   n Xy% | j | t j d | j j
  } Wn( t k
 r}
 |  j$ |  |
 d	   n X|  j | j d
  } |  j | j d
  } | j t j @rd | j | j d | j d f } n$ d | j | j d | j d f } | |  j k s&| |  j k r5t |   n |  j j d |  yJ | j j  d d  } d | j j
 | f } | j | t j! d |  } Wn( t k
 r}
 |  j$ |  |
 d   n X|  j | j d
  } d | j | j d f } | |  j k rt |   q#|  j j d |  n  d  S(   Ns   failed to connect lsa servers#   failed to query LSA_POLICY_INFO_DNSs(   LocalDomain Netbios[%s] DNS[%s] SID[%s]
s4   trusted domain object does not exist for domain [%s]s,   QueryTrustedDomainInfoByName(INFO_EX) faileds%   LocalTDO Netbios[%s] DNS[%s] SID[%s]
s!   failed to connect netlogon serveri   s!   NETLOGON_CONTROL_TC_VERIFY failedi    sG   LocalValidation: DC[%s] CONNECTION[%s] TRUST[%s] VERIFY_STATUS_RETURNEDi   s0   LocalValidation: DC[%s] CONNECTION[%s] TRUST[%s]s   OK: %s
s   \R   s   %s\%ss"   NETLOGON_CONTROL_REDISCOVER faileds&   LocalRediscover: DC[%s] CONNECTION[%s]R  R  s   failed to locate remote serversH   RemoteValidation: DC[%s] CONNECTION[%s] TRUST[%s] VERIFY_STATUS_RETURNEDs1   RemoteValidation: DC[%s] CONNECTION[%s] TRUST[%s]s'   RemoteRediscover: DC[%s] CONNECTION[%s](&   R   R  R  R  RX   R  R
  RY   RZ   R   Rf   R\   R  R  R  R'  R  R  R   R  R]   R  R  R   R  R  R  R  R  R  R  R  R6  t   NETLOGON_CONTROL_REDISCOVERR  R   R  R  (    RF   R   R<   R>   R=   R  R,  R  R  R  R  R  R  R  R  R  R  R  R  R   R  t   domain_and_servert   local_trust_rediscovert   local_rediscoverR  R  R!  R"  R#  R$  t   remote_trust_rediscovert   remote_rediscover(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRI   
  s    								

		

	N(   RJ   RK   RL   RM   RN   RO   RQ   RP   R  RR   R   RT   RU   RD   RI   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR+  
  s   



	t   cmd_domain_trust_namespacesc           B   s  e  Z d  Z d Z i e j d 6e j d 6e d 6Z e	 d d d d d	 d
 d d dA g d d d d d dA e	 d d d d d d d d e e	 d d d d d d d d d d g  e	 d d d d d d d d d d g  e	 d d d d d d d  d d! d g  e	 d" d d d d d d# d d$ d g  e	 d% d d d d& d d' d d( d g  e	 d) d d d d& d d* d d+ d g  e	 d, d d d d- d d. d d/ d g  e	 d0 d d d d- d d1 d d2 d g  e	 d3 d d d d d d4 d d5 d g  e	 d6 d d d d d d7 d d8 d g  e	 d9 d d d d d d: d d; d g  e	 d< d d d d d d= d d> d g  g Z d? g Z dA dA dA dA dA e g  g  g  g  g  g  g  g  g  g  g  g  d@  Z RS(B   s   Manage forest trust namespaces.s   %prog [DOMAIN] [options]R<   R>   R  s	   --refreshR@   Rp   Rg   s   check|storeRq   t   checkt   storeR?   sL   List and maybe store refreshed forest trust information: 'check' or 'store'.RT  t   refreshRv   s   --enable-allRd   Re   sA   Try to update disabled entries, not allowed with --refresh=check.t
   enable_alls   --enable-tlnRb  t	   DNSDOMAINs?   Enable a top level name entry. Can be specified multiple times.t
   enable_tlns   --disable-tlns@   Disable a top level name entry. Can be specified multiple times.t   disable_tlns   --add-tln-exsA   Add a top level exclusion entry. Can be specified multiple times.t
   add_tln_exs   --delete-tln-exsD   Delete a top level exclusion entry. Can be specified multiple times.t   delete_tln_exs   --enable-nbt   NETBIOSDOMAINsI   Enable a netbios name in a domain entry. Can be specified multiple times.t	   enable_nbs   --disable-nbsJ   Disable a netbios name in a domain entry. Can be specified multiple times.t
   disable_nbs   --enable-sidt	   DOMAINSIDs@   Enable a SID in a domain entry. Can be specified multiple times.t   enable_sid_strs   --disable-sidsA   Disable a SID in a domain entry. Can be specified multiple times.t   disable_sid_strs   --add-upn-suffixsV   Add a new uPNSuffixes attribute for the local forest. Can be specified multiple times.t   add_upns   --delete-upn-suffixs^   Delete an existing uPNSuffixes attribute of the local forest. Can be specified multiple times.t
   delete_upns   --add-spn-suffixs[   Add a new msDS-SPNSuffixes attribute for the local forest. Can be specified multiple times.t   add_spns   --delete-spn-suffixsc   Delete an existing msDS-SPNSuffixes attribute of the local forest. Can be specified multiple times.t
   delete_spns   domain?c   G   
   C   s   t  } | d  k r5| d k r1 t d |   n  | rF t d   n  t |  d k rg t d   n  t |  d k r t d   n  t |	  d k r t d   n  t |
  d k r t d   n  t |  d k r t d	   n  t |  d k rt d
   n  t |  d k r-t d   n  t |  d k rNt d   n  t |  d k rx3 | D]+ } | j d  sqgn  t d |   qgWt } n  t |  d k rx3 | D]+ } | j d  sqn  t d |   qWt } n  xM | D]E } x< | D]4 } | j   | j   k r(qn  t d |   qWqWt |  d k rx3 | D]+ } | j d  stqYn  t d |   qYWt } n  t |  d k rx3 | D]+ } | j d  sqn  t d |   qWt } n  x | D]E } x< | D]4 } | j   | j   k rqn  t d |   qWqWn t |  d k rVt d   n  t |  d k rwt d   n  t |  d k rt d   n  t |  d k rt d   n  | d  k	 r
| d k rt } n  | r| d k rt d |   n  t |  d k r t d   n  t |  d k rAt d   n  t |	  d k rbt d   n  t |
  d k rt d   n  t |  d k rt d   n  t |  d k rt d   n  t |  d k rt d   n  t |  d k rt d    qn| r|t } t |  d k r7t d!   n  t |  d k rXt d"   n  t |  d k r|t d#   q|n  t |  d k rt } n  t |  d k rt } n  xM | D]E } x< | D]4 } | j   | j   k rqn  t d$ |   qWqWt |	  d k rSx3 |	 D]+ } | j d  s6qn  t d% |   qWt } n  t |
  d k rx3 |
 D]+ } | j d  sqln  t d& |   qlWt } n  xM |	 D]E } x< |
 D]4 } | j   | j   k rqn  t d' |   qWqWt |  d k rt } n  t |  d k r*t } n  xM | D]E } x< | D]4 } | j   | j   k rbq>n  t d( |   q>Wq1Wg  } xT | D]L } y t j	 |  } Wn# t
 k
 r} t d) |   n X| j |  qWg  } xT | D]L } y t j	 |  } Wn# t
 k
 r"} t d* |   n X| j |  qWt |  d k rOt } n  t |  d k rjt } n  xA | D]9 } x0 | D]( } | | k rq~n  t d+ |   q~WqqWt j } | r| t j O} n  |  j | |  } y |  j   } Wn( t k
 r	} |  j |  | d,   n Xy |  j | |  \ }  }! Wn( t k
 r`	} |  j |  | d-   n X|  j j d. |! j j |! j j |! j f  | d  k ry |  j   }" Wn( t k
 r	} |  j |  | d/   n Xy |  j |" |  }# Wn( t k
 r
} |  j |  | d0   n X|# j |# j k rF
t d1 |# j |# j f   n  y |" j |# j d  d  }$ Wn t k
 r} |  j  | |  j!  r
t d2 |  j"   n  |  j  | |  j#  r
t d2 |  j"   n  |  j  | |  j$  r
t d2 |  j"   n  |  j |  | d3   n X|  j j d4  |  j% |$ d5 |! j j y |  j&   }% Wn( t k
 rq} |  j |  | d6   n Xd7 t' |% j(    }& d8 d9 g }' y5 |% j) d: |& d; t* j+ d< d= d> |'  }( |( d }) Wn+ t* j, k
 r} |  j- |  | d?   n Xg  }* d8 |) k r|* j. |) d8  n  g  }+ d9 |) k rC|+ j. |) d9  n  |  j j d@ t |*   x( |* D]  }, |  j j dA dB |, f  qdW|  j j dC t |+   x( |+ D]  }, |  j j dA dB |, f  qW| sd  St  }- g  }. |. j. |*  t  }/ g  }0 |0 j. |+  x | D] }1 d  }2 xL t/ d t |.   D]5 }3 |. |3 }, |, j   |1 j   k r`q2n  |3 }2 Pq2W|2 d  k	 rt dD |1   n  |. j |1  t }- qWx | D] }1 d  }2 xL t/ d t |.   D]5 }3 |. |3 }, |, j   |1 j   k rqn  |3 }2 PqW|2 d  k r"t dE |1   n  |. j0 |2  t }- qWx | D] }4 d  }2 xL t/ d t |0   D]5 }3 |0 |3 }, |, j   |4 j   k rqbn  |3 }2 PqbW|2 d  k	 rt dF |4   n  |0 j |4  t }/ q@Wx | D] }4 d  }2 xL t/ d t |0   D]5 }3 |0 |3 }, |, j   |4 j   k r(qn  |3 }2 PqW|2 d  k rRt dG |4   n  |0 j0 |2  t }/ qW|  j j dH t |.   x( |. D]  }, |  j j dA dB |, f  qW|  j j dI t |0   x( |0 D]  }, |  j j dA dB |, f  qWt* j1   }5 |) j2 |5 _2 |- r0t* j3 |. t* j4 d8  |5 d8 <n  |/ rUt* j3 |0 t* j4 d9  |5 d9 <n  y |% j5 |5  Wn+ t* j, k
 r} |  j- |  | dJ   n Xy |" j |# j d  d  }6 Wn( t k
 r} |  j |  | d3   n X|  j j dK  |  j% |6 d5 |! j j d  Sy1 t j6   }7 | |7 _ | j7 |  |7 t j8  }8 WnP t k
 r} |  j  | |  j9  rst dL |   n  |  j |  | dM   n X|  j j dN |8 j: j |8 j j |8 j f  |8 j; t j< @st dO |   n  | d  k	 r y |  j   }" Wn( t k
 r!} |  j |  | d/   n Xy |  j |" |  }# Wn( t k
 rb} |  j |  | d0   n XdP }9 | d k rt= j> }: | rd }9 qn d }: y" |" j |# j |8 j j |:  }; Wn( t k
 r} |  j |  | d3   n Xy% | j? |  |8 j t j@ |; |9  }< Wn( t k
 r2} |  j |  | dQ   n X|  j j dR  |  j% |; d5 |8 j j dS |< | d k ry7 t j6   }7 |8 j j |7 _ | jA |  |7 t j@  }6 Wn( t k
 r} |  j |  | dT   n X|  j j dK  |  j% |6 d5 |8 j j n  d  Sy7 t j6   }7 |8 j j |7 _ | jA |  |7 t j@  }= Wn( t k
 ra} |  j |  | dT   n X|  j j dU  |  j% |= d5 |8 j j | sd  Sg  }> |> j. |= jB  t jC   }? t |>  |? _D |> |? _B | rx t/ d t |? jB   D]q }3 |? jB |3 }@ |@ jE t jF k rqn  |? jB |3 jG d k r5qn  d |? jB |3 _H |? jB |3 jG t jI M_G qWx t/ d t |? jB   D] }3 |? jB |3 }@ |@ jE t j@ k rq|n  |? jB |3 jG d k rq|n  d |? jB |3 _H |? jB |3 jG t jJ M_G |? jB |3 jG t jK M_G q|Wn  x | D] }A d  }2 xp t/ d t |? jB   D]V }3 |? jB |3 }@ |@ jE t jF k req:n  |@ jL j j   |A j   k rq:n  |3 }2 Pq:W|2 d  k rt dV |A   n  |? jB |2 jG t jI @st dW |A   n  d |? jB |2 _H |? jB |2 jG t jI M_G qWx| D]}A d  }2 xp t/ d t |? jB   D]V }3 |? jB |3 }@ |@ jE t jF k rbq7n  |@ jL j j   |A j   k rq7n  |3 }2 Pq7W|2 d  k rt dX |A   n  |? jB |2 jG t jM @rt dY |A   n  d |? jB |2 _H |? jB |2 jG t jI M_G |? jB |2 jG t jM O_G qWx|	 D]}B d  }2 xp t/ d t |? jB   D]V }3 |? jB |3 }@ |@ jE t jN k rxqMn  |@ jL j j   |B j   k rqMn  |3 }2 PqMW|2 d  k	 rt dZ |B   n  d[ |B j   }C d  }2 x t/ d t |? jB   D]| }3 |? jB |3 }@ |@ jE t jF k r qn  d[ |@ jL j j   }D |C |D k rUt d\ |B   n  |C jO |D  sjqn  |3 }2 PqW|2 d  k rt d] |B   n  t jP   }@ t jN |@ _E d |@ _G d |@ _H |B |@ jL _ g  }> |> j. |? jB  |> jQ |2 dP |@  t |>  |? _D |> |? _B q(Wx |
 D] }B d  }2 xp t/ d t |? jB   D]V }3 |? jB |3 }@ |@ jE t jN k rgq<n  |@ jL j j   |B j   k rq<n  |3 }2 Pq<W|2 d  k rt d^ |B   n  g  }> |> j. |? jB  |> j0 |2  t |>  |? _D |> |? _B qWx | D] }E d  }2 xs t/ d t |? jB   D]Y }3 |? jB |3 }@ |@ jE t j@ k rKq n  |@ jL jR j j   |E j   k rrq n  |3 }2 Pq W|2 d  k rt d_ |E   n  |? jB |2 jG t jJ @st d` |E   n  d |? jB |2 _H |? jB |2 jG t jJ M_G qWx| D]}E d  }2 xs t/ d t |? jB   D]Y }3 |? jB |3 }@ |@ jE t j@ k rKq n  |@ jL jR j j   |E j   k rrq n  |3 }2 Pq W|2 d  k rt da |E   n  |? jB |2 jG t jS @rt db |E   n  d |? jB |2 _H |? jB |2 jG t jJ M_G |? jB |2 jG t jS O_G qWx | D] } d  }2 xd t/ d t |? jB   D]J }3 |? jB |3 }@ |@ jE t j@ k rdq9n  |@ jL jT | k r|q9n  |3 }2 Pq9W|2 d  k rt dc |   n  |? jB |2 jG t jK @st dd |E   n  d |? jB |2 _H |? jB |2 jG t jK M_G qWx| D] } d  }2 xd t/ d t |? jB   D]J }3 |? jB |3 }@ |@ jE t j@ k rUq*n  |@ jL jT | k rmq*n  |3 }2 Pq*W|2 d  k rt de |   n  |? jB |2 jG t jU @rt df |E   n  d |? jB |2 _H |? jB |2 jG t jK M_G |? jB |2 jG t jU O_G qWy% | j? |  |8 j t j@ |? d  }F Wn( t k
 rW} |  j |  | dQ   n X|  j j dg  |  j% |? d5 |8 j j dS |F y7 t j6   }7 |8 j j |7 _ | jA |  |7 t j@  }6 Wn( t k
 r} |  j |  | dT   n X|  j j dK  |  j% |6 d5 |8 j j d  S(h   NR5  s'   --refresh=%s not allowed without DOMAINs'   --enable-all not allowed without DOMAINi    s'   --enable-tln not allowed without DOMAINs(   --disable-tln not allowed without DOMAINs'   --add-tln-ex not allowed without DOMAINs*   --delete-tln-ex not allowed without DOMAINs&   --enable-nb not allowed without DOMAINs'   --disable-nb not allowed without DOMAINs'   --enable-sid not allowed without DOMAINs(   --disable-sid not allowed without DOMAINs   *.sE   value[%s] specified for --add-upn-suffix should not include with '*.'sH   value[%s] specified for --delete-upn-suffix should not include with '*.'s@   value[%s] specified for --add-upn-suffix and --delete-upn-suffixsE   value[%s] specified for --add-spn-suffix should not include with '*.'sH   value[%s] specified for --delete-spn-suffix should not include with '*.'s@   value[%s] specified for --add-spn-suffix and --delete-spn-suffixs1   --add-upn-suffix not allowed together with DOMAINs4   --delete-upn-suffix not allowed together with DOMAINs1   --add-spn-suffix not allowed together with DOMAINs4   --delete-spn-suffix not allowed together with DOMAINs3   --enable-all not allowed together with --refresh=%ss0   --enable-tln not allowed together with --refreshs1   --disable-tln not allowed together with --refreshs0   --add-tln-ex not allowed together with --refreshs3   --delete-tln-ex not allowed together with --refreshs/   --enable-nb not allowed together with --refreshs0   --disable-nb not allowed together with --refreshs0   --enable-sid not allowed together with --refreshs1   --disable-sid not allowed together with --refreshs3   --enable-tln not allowed together with --enable-alls2   --enable-nb not allowed together with --enable-alls3   --enable-sid not allowed together with --enable-alls6   value[%s] specified for --enable-tln and --disable-tlnsA   value[%s] specified for --add-tln-ex should not include with '*.'sD   value[%s] specified for --delete-tln-ex should not include with '*.'s8   value[%s] specified for --add-tln-ex and --delete-tln-exs4   value[%s] specified for --enable-nb and --disable-nbs7   value[%s] specified for --enable-sid is not a valid SIDs8   value[%s] specified for --disable-sid is not a valid SIDs6   value[%s] specified for --enable-sid and --disable-sids   failed to connect lsa servers#   failed to query LSA_POLICY_INFO_DNSs(   LocalDomain Netbios[%s] DNS[%s] SID[%s]
s!   failed to connect netlogon servers   failed to get netlogon dc infos1   The local domain [%s] is not the forest root [%s]s@   LOCAL_DC[%s]: netr_DsRGetForestTrustInformation() not supported.s*   netr_DsRGetForestTrustInformation() faileds    Own forest trust information...
R  s   failed to connect to SamDBs   CN=Partitions,%st   uPNSuffixess   msDS-SPNSuffixesR"  R#  R  s   (objectClass=crossRefContainer)R   s   failed to search partition dns#   Stored uPNSuffixes attributes[%d]:
s   TLN: %-32s DNS[*.%s]
R   s(   Stored msDS-SPNSuffixes attributes[%d]:
sB   Entry already present for value[%s] specified for --add-upn-suffixs?   Entry not found for value[%s] specified for --delete-upn-suffixsB   Entry already present for value[%s] specified for --add-spn-suffixs?   Entry not found for value[%s] specified for --delete-spn-suffixs#   Update uPNSuffixes attributes[%d]:
s(   Update msDS-SPNSuffixes attributes[%d]:
s   failed to update partition dns#   Stored forest trust information...
s4   trusted domain object does not exist for domain [%s]s,   QueryTrustedDomainInfoByName(INFO_EX) faileds%   LocalTDO Netbios[%s] DNS[%s] SID[%s]
sI   trusted domain object for domain [%s] is not marked as FOREST_TRANSITIVE.i   s&   lsaRSetForestTrustInformation() faileds"   Fresh forest trust information...
R  s(   lsaRQueryForestTrustInformation() faileds"   Local forest trust information...
s8   Entry not found for value[%s] specified for --enable-tlnsG   Entry found for value[%s] specified for --enable-tln is already enableds9   Entry not found for value[%s] specified for --disable-tlnsI   Entry found for value[%s] specified for --disable-tln is already disableds>   Entry already present for value[%s] specified for --add-tln-exs   .%ss:   TLN entry present for value[%s] specified for --add-tln-exs>   No TLN parent present for value[%s] specified for --add-tln-exs;   Entry not found for value[%s] specified for --delete-tln-exs7   Entry not found for value[%s] specified for --enable-nbsF   Entry found for value[%s] specified for --enable-nb is already enableds7   Entry not found for value[%s] specified for --delete-nbsH   Entry found for value[%s] specified for --disable-nb is already disableds8   Entry not found for value[%s] specified for --enable-sidsG   Entry found for value[%s] specified for --enable-sid is already enableds8   Entry not found for value[%s] specified for --delete-sidsI   Entry found for value[%s] specified for --disable-sid is already disableds$   Updated forest trust information...
(V   R   RD   R   R   R   R   R   R   R   R   t	   TypeErrorRb  R   R  R  R  R  RX   R  R
  RY   RZ   R   Rf   R\   R  R  R  R]   t   forest_nameR  R  R  R  R  R  R  R  R  RS   R)  R'  R*  R]  R<  R  R  Rz  t   popR-  R,  R.  R/  R0  R  R  R'  R  R  R  R  R   R  R  R  R  Ry  R  R  R@   R}  R  t   timet   LSA_TLN_DISABLED_MASKt   LSA_NB_DISABLED_MASKt   LSA_SID_DISABLED_MASKR|  Rp  R~  t   endswitht   ForestTrustRecordt   insertR  Rv  R   Rt  (G   RF   R   R<   R  R>   R6  R7  R9  R:  R;  R<  RA  RB  R>  R?  RC  RD  RE  RF  t   require_updatet   nR   R  t
   enable_sidR   RP  R  R  t   disable_sidR  R  R  R  R  R  R  t   own_forest_infot   local_samdbt   local_partitions_dnR   Rm  t
   stored_msgt   stored_upn_valst   stored_spn_valsR  t   replace_upnt   update_upn_valst   replace_spnt   update_spn_valst   upnt   idxRK  t   spnt
   update_msgt   stored_forest_infoR  R  t   lsa_update_checkt   netlogon_update_tdot   fresh_forest_infot   fresh_forest_collisionR  Ry  t   update_forest_infoR0   R  t   tln_ext   tln_dott   r_dott   nbt   update_forest_collision(    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRI     s   																		







												!		!!		N(   RJ   RK   RL   RM   RN   RO   RQ   R  RR   R   RD   R   RT   RU   RI   (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyR3  E  s   


	t   cmd_domain_trustc           B   sb   e  Z d  Z i  Z e   e d <e   e d <e   e d <e   e d <e   e d <e	   e d <RS(   s#   Domain and forest trust management.t   listRY  t   createR;  R  t
   namespaces(
   RJ   RK   RL   t   subcommandsR  R  R  R%  R+  R3  (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRo  =  s   t
   cmd_domainc           B   s   e  Z d  Z i  Z e   e d <e d k	 r; e   e d <n  e   e d <e   e d <e	   e d <e
   e d <e   e d <e   e d <e   e d	 <e   e d
 <e   e d <RS(   s   Domain management.t   demotet   exportkeytabR   R+   R  t   dcpromot   levelt   passwordsettingst   classicupgradet   samba3upgradet   trustN(   RJ   RK   RL   Rs  R  R;   RD   RV   Rc   R  R  RR  Rs  R  R  Ro  (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyRt  H  s   (f   t   samba.getoptt   getoptRN   R*  Rf   R1   R   R  R  R   R   R    t	   samba.netR   R   t   samba.ntaclsR   t
   samba.joinR   R   R   t
   samba.authR   t   samba.samdbR   t	   samba.ndrR   R	   R
   t   samba.dcerpcR   R   R   R   R   R   t   samba.dcerpc.samrR   R   t   samba.netcmdR   R   R   R   t   samba.netcmd.commonR   t   samba.samba3R   R   R  t   samba.upgradeR   t   samba.drs_utilsR   R   R   R   R   R    t
   samba.dsdbR!   R"   R#   R$   R%   R&   R'   R(   R)   R*   t   samba.provisionR+   R,   t   samba.provision.commonR-   R.   R/   R:   t   samba.dckeytabt   ImportErrorRD   R;   RV   Rc   R  R  R  RR  Rs  R  R  RP   R  R  R  R  R  R%  R+  R3  Ro  Rt  (    (    (    s7   /usr/lib/python2.7/dist-packages/samba/netcmd/domain.pyt   <module>   s~   ""F	
 CL` -d  )  