%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/ldapmod.pyo

�
���^c@@sdZddlmZmZmZddlZddlZddlZddl	m
Z
ddlmZy"ddl
Z
ddlZ
eZWnek
r�eZnXeje�ZdZd�Zdd�Zd	�Zdddd
�Zdefd��YZdS(
ut
Salt interface to LDAP commands

:depends:   - ldap Python module
:configuration: In order to connect to LDAP, certain configuration is required
    in the minion config on the LDAP server. The minimum configuration items
    that must be set are:

    .. code-block:: yaml

        ldap.basedn: dc=acme,dc=com (example values, adjust to suit)

    If your LDAP server requires authentication then you must also set:

    .. code-block:: yaml

        ldap.anonymous: False
        ldap.binddn: admin
        ldap.bindpw: password

    In addition, the following optional values may be set:

    .. code-block:: yaml

        ldap.server: localhost (default=localhost, see warning below)
        ldap.port: 389 (default=389, standard port)
        ldap.tls: False (default=False, no TLS)
        ldap.no_verify: False (default=False, verify TLS)
        ldap.anonymous: True (default=True, bind anonymous)
        ldap.scope: 2 (default=2, ldap.SCOPE_SUBTREE)
        ldap.attrs: [saltAttr] (default=None, return all attributes)

.. warning::

    At the moment this module only recommends connection to LDAP services
    listening on ``localhost``. This is deliberate to avoid the potentially
    dangerous situation of multiple minions sending identical update commands
    to the same LDAP server. It's easy enough to override this behavior, but
    badness may ensue - you have been warned.
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tCommandExecutionErroruldapcC@str
tStdfS(u9
    Only load this module if the ldap config is set
    uGThe ldapmod execution module cannot be loaded: ldap config not present.(tHAS_LDAPt__virtualname__tFalse(((s8/usr/lib/python2.7/site-packages/salt/modules/ldapmod.pyt__virtual__CscK@s`|dkr|}n||kr.||}ntddj|��}tjjj|dt�S(u�
    Return a value for 'name' from command line args then config file options.
    Specify 'key' if the config file option is not the same as 'name'.
    u
config.optionuldap.{0}tto_strN(tNonet__salt__tformattsalttutilstdatatdecodetTrue(tnametkeytkwargstvalue((s8/usr/lib/python2.7/site-packages/salt/modules/ldapmod.pyt_configNs	
cK@sOi}x9ddddddddgD]}t||�||<q%Wt|�jS(	uP
    Instantiate LDAP Connection class and return an LDAP connection object
    uuriuserveruportutlsu	no_verifyubinddnubindpwu	anonymous(Rt_LDAPConnectiontldap(RtconnargsR((s8/usr/lib/python2.7/site-packages/salt/modules/ldapmod.pyt_connect\s
cK@sL|stdd�}n|s-td�}n|dkrBd}n|dkr]td�}nt|�}tj�}tjd||||�|j|t|�||�}tj�|}|dkr�tj	t
|dd	��d
}	ntj	t
|d��d}	i|d
6t|�d6i|	d6tj	t
|d��d6d6}
|
S(uz
    Run an arbitrary LDAP query and return the results.

    CLI Example:

    .. code-block:: bash

        salt 'ldaphost' ldap.search "filter=cn=myhost"

    Return data:

    .. code-block:: python

        {'myhost': {'count': 1,
                    'results': [['cn=myhost,ou=hosts,o=acme,c=gb',
                                 {'saltKeyValue': ['ntpserver=ntp.acme.local',
                                                   'foo=myfoo'],
                                  'saltState': ['foo', 'bar']}]],
                    'time': {'human': '1.2ms', 'raw': '0.00123'}}}

    Search and connection options can be overridden by specifying the relevant
    option as key=value pairs, for example:

    .. code-block:: bash

        salt 'ldaphost' ldap.search filter=cn=myhost dn=ou=hosts,o=acme,c=gb
        scope=1 attrs='' server='localhost' port='7393' tls=True bindpw='ssh'
    udnubasednuscopeuuattrsu=Running LDAP search with filter:%s, dn:%s, scope:%s, attrs:%sg�������?i�iumsiusuresultsucountuhumaniurawutimeN(RR
Rttimetlogtdebugtsearch_stintRt	text_typetroundtlen(tfiltertdntscopetattrsRt_ldaptstarttresultstelapsedt	elapsed_htret((s8/usr/lib/python2.7/site-packages/salt/modules/ldapmod.pytsearchhs.!	#
*RcB@seZdZd�ZRS(u#
    Setup an LDAP connection.
    c	
C@s<||_||_||_||_||_||_|jdkrcdj|j|j�|_ny�|r�tjtj	tj
�ntjdj|j��|_d|j_|jjtj
d�|jr�|jj�n|s|jj|j|j�nWn4tk
r7}	tdj|j|j|	���nXdS(uE
        Bind to an LDAP directory using passed credentials.
        uuldap://{0}:{1}u{0}iiu-Failed to bind to LDAP server {0} as {1}: {2}N(turitservertportttlstbinddntbindpwRRt
set_optiontOPT_X_TLS_REQUIRE_CERTtOPT_X_TLS_NEVERt
initializetprotocol_versiont
OPT_REFERRALStstart_tls_st
simple_bind_st	ExceptionR(
tselfR.R/R0R1t	no_verifyR2R3t	anonymoust
ldap_error((s8/usr/lib/python2.7/site-packages/salt/modules/ldapmod.pyt__init__�s0						
	 (t__name__t
__module__t__doc__RA(((s8/usr/lib/python2.7/site-packages/salt/modules/ldapmod.pyR�s(RDt
__future__RRRtloggingRtsalt.utils.dataR
tsalt.extRtsalt.exceptionsRRtldap.modlistRRtImportErrorRt	getLoggerRBRRRR
RRR-tobjectR(((s8/usr/lib/python2.7/site-packages/salt/modules/ldapmod.pyt<module>)s*


		
;

Zerion Mini Shell 1.0