ó
E®Uc           @   s   d  d l  Z  d  d l Z d  d l j 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 e
 f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   system_session(   t   SamDB(   t   Commandt   CommandErrort   Option(   t   dbcheckt   cmd_dbcheckc           B   sâ  e  Z d  Z d Z i e j d 6e j d 6e j d 6Z d g Z	 e
 d d d d	 d
 d d ƒe
 d d d d	 e d d d d ƒe
 d d d d	 e d d d d ƒe
 d d d d	 e d d d d ƒe
 d d d d d d d	 e d d ƒe
 d d d d d d	 e d d ƒe
 d d d  d	 d3 d d! ƒe
 d" d d# d	 e d d d d$ ƒe
 d% d d& d	 e d d d d' ƒe
 d( d d) d	 e d d d d* ƒe
 d+ d, d d- d. e d/ d0 d d1 ƒg Z d3 d3 e e e e e d
 d3 d3 d3 d3 e e e d2 „ Z RS(4   s#   Check local AD database for errors.s   %prog [<DN>] [options]t	   sambaoptst   versionoptst   credoptss   DN?s   --scopet   destt   scopet   defaultt   SUBt   helps>   Pass search scope that builds DN list. Options: SUB, ONE, BASEs   --fixt   fixt   actiont
   store_trues   Fix any errors founds   --yest   yess?   don't confirm changes, just do them all as a single transactions   --cross-ncst	   cross_ncss   cross naming context boundariess   -vs	   --verboset   verboses   Print more details of checkings   --quiett   quiets   don't print details of checkings   --attrst   attrss-   list of attributes to check (space separated)s	   --reindext   reindexs   force database re-indexs   --force-modulest   force_modulessV   force loading of Samba modules and ignore the @MODULES record (for very old databases)s   --reset-well-known-aclst   reset_well_known_aclssG   reset ACLs on objects with well known default ACL values to the defaults   -Hs   --URLsF   LDB URL for database or target server (defaults to local SAM database)t   typet   metavart   URLt   Hc         C   s  |
 j  ƒ  } | d  k	 o$ | j d ƒ } | rE |	 j | d t ƒ} n d  } | r t d t ƒ  d | d | d | d d g ƒ } nB y( t d t ƒ  d | d | d | ƒ } Wn t d	 | ƒ ‚ n X| d  k sÖ | rß | } n$ t d t ƒ  d d  d | d | ƒ } i t j	 d
 6t j
 d 6t j d 6} | j ƒ  } | | k rRt d | ƒ ‚ n  | | } d g } | r{| j d ƒ n  | r‘| j d ƒ n  | s£d g } n | j ƒ  } t } | rÔ| rÔ| j ƒ  t } n  yÚ t | d | d | d | d | d | d | d | ƒ} | rK|  j j d ƒ d } | j ƒ  r­|  j j d ƒ q­nb | r‰|  j j d ƒ d } | j ƒ  r­|  j j d ƒ q­n$ | j d | d | d  | d! | ƒ } Wn | rÇ| j ƒ  n  ‚  n X| rá| j ƒ  n  | d k rýt j d" ƒ n  d  S(#   Nt   ldapt   fallback_machinet   session_infot   urlt   credentialst   lpt   optionss   modules=samba_dsdbst   Failed to connect to DB at %s.  If this is a really old sam.ldb (before alpha9), then try again with --force-modulesR   t   BASEt   ONEs   Unknown scope %ss   show_deleted:1s   paged_results:1:1000s   search_options:1:2t   *t   samdb_schemaR   R   R   R   t   in_transactionR   s   Re-indexing...
i    s   completed re-index OK
s   Resetting @MODULES...
s   completed @MODULES reset OK
t   DNR   t   controlsR   i   (   t   get_loadparmt   Nonet
   startswitht   get_credentialst   TrueR   R    R   t   ldbt   SCOPE_SUBTREEt
   SCOPE_BASEt   SCOPE_ONELEVELt   uppert   appendt   splitt   Falset   transaction_startR   t   outft   writet   reindex_databaset   reset_modulest   check_databaset   transaction_cancelt   transaction_committ   syst   exit(   t   selfR*   R   R   R   R   R   R   R   R	   R   R   R   R   R   R   R#   t	   over_ldapt   credst   samdbR(   t	   scope_mapt   search_scopeR+   t   started_transactiont   chkt   error_count(    (    s8   /usr/lib/python2.7/dist-packages/samba/netcmd/dbcheck.pyt   run@   st    	$
	
		N(   t   __name__t
   __module__t   __doc__t   synopsisR$   t   SambaOptionst   VersionOptionst   CredentialsOptionsDoublet   takes_optiongroupst
   takes_argsR   R8   R-   t   strt   takes_optionsRL   (    (    (    s8   /usr/lib/python2.7/dist-packages/samba/netcmd/dbcheck.pyR      s<   

	!!!	(   R1   RA   t   samba.getoptt   getoptR$   t
   samba.authR    t   samba.samdbR   t   samba.netcmdR   R   R   t   samba.dbcheckerR   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/samba/netcmd/dbcheck.pyt   <module>   s   