
    Vh                     z    d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZmZ  G d de      Zd	 Zed
k(  r e        yy)    )absolute_importdivisionprint_functiona
  
---
module: edit_ldap
version_added: "1.0.0"
author:
    - WangBaoshan (@ieisystem)
short_description: Set ldap information
description:
   - Set ldap information on ieisystem Server.
notes:
   - Does not support C(check_mode).
options:
    enable:
        description:
            - LDAP/E-Directory Authentication Status.
        choices: ['enable', 'disable']
        type: str
    encry:
        description:
            - Encryption Type.
        choices: ['no', 'SSL', 'StartTLS']
        type: str
    address:
        description:
            - Server Address.
        type: str
    server_port:
        description:
            - Server Port. Specify the LDAP/E-Directory Port.
        type: int
    dn:
        description:
            - Bind DN. The Bind DN is used in bind operations, which authenticates the client to the server.
            - Bind DN is a string of 4 to 64 alphanumeric characters.
            - It must start with an alphabetical character.
            - Special Symbols like dot(.), comma(, ), hyphen(-), underscore(_), equal-to(=) are allowed.
        type: str
    code:
        description:
            - Password. The Bind password is also used in the bind authentication operations between client and server.
            - Required when I(enable=enable).
        type: str
    base:
        description:
            - Search Base.
            - The Search Base allows the LDAP/E-Directory server to find which part of the external directory tree is to be searched.
            - This search base may be equivalent to the organization or the group of the external directory.
            - Search base is a string of 4 to 64 alphanumeric characters.
            - It must start with an alphabetical character.
            - Special Symbols like dot(.), comma(, ), hyphen(-), underscore(_), equal-to(=) are allowed.
        type: str
    attr:
        description:
            - Attribute of User Login.
            - The Attribute of User Login field indicates to the LDAP/E-Directory server which attribute should be used to identify the user.
        choices: ['cn', 'uid']
        type: str
    cn:
        description:
            - Common name type.
            - Required when I(encry=StartTLS).
        choices: ['ip', 'fqdn']
        type: str
    ca:
        description:
            - CA certificate file path.
            - Required when I(encry=StartTLS).
        type: str
    ce:
        description:
            - Certificate file path.
            - Required when I(encry=StartTLS).
        type: str
    pk:
        description:
            - Private Key file path.
            - Required when I(encry=StartTLS).
        type: str
extends_documentation_fragment:
    - ieisystem.inmanage.inmanage
a  
- name: Ldap test
  hosts: inmanage
  connection: local
  gather_facts: false
  vars:
    inmanage:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"

  tasks:

  - name: "Set ldap information"
    ieisystem.inmanage.edit_ldap:
      enable: "disable"
      provider: "{{ inmanage }}"

  - name: "Set ldap information"
    ieisystem.inmanage.edit_ldap:
      enable: "enable"
      encry: "SSL"
      address: "100.2.2.2"
      server_port: 389
      dn: "cn=manager,ou=login,dc=domain,dc=com"
      code: "123456"
      base: "cn=manager"
      attr: "uid"
      provider: "{{ inmanage }}"
a1  
message:
    description: Messages returned after module execution.
    returned: always
    type: str
state:
    description: Status after module execution.
    returned: always
    type: str
changed:
    description: Check to see if a change was made on the device.
    returned: always
    type: bool
)AnsibleModule)inmanage_argument_specget_connectionc                   *    e Zd Zd Zd Zd Zd Zd Zy)LDAPc                 ^    || _         d | _        | j                          t               | _        y )N)specmoduleinit_moduledictresults)selfargument_specs     p/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/ieisystem/inmanage/plugins/modules/edit_ldap.py__init__zLDAP.__init__   s%    !	v    c                 <    t        | j                  d      | _        y)zInit module objectF)r   supports_check_modeN)r   r   r   r   s    r   r   zLDAP.init_module   s     $))@r   c                     d| j                   j                  d<   t        | j                         | _        | j                  d   dk(  rd| j                  d<   y y )Nsetldap
subcommandStateSuccessTchanged)r   paramsr   r   r   s    r   run_commandzLDAP.run_command   sJ    +4<(%dkk2<< I-&*DLL# .r   c                 P     | j                   j                  di | j                   y)zShow resultN )r   	exit_jsonr   r   s    r   show_resultzLDAP.show_result   s    --r   c                 D    | j                          | j                          y)WorkerN)r    r$   r   s    r   workz	LDAP.work   s    r   N)__name__
__module____qualname__r   r   r    r$   r'   r"   r   r   r
   r
      s    @+.r   r
   c                     t        t        ddddg      t        ddg d      t        dd      t        dd      t        dd      t        dd      t        dd      t        ddd	d
g      t        ddddg      t        dd      t        dd      t        dd            } | j                  t               t        |       }|j	                          y )NstrFenabledisable)typerequiredchoices)noSSLStartTLS)r/   r0   intcnuidipfqdn)r-   encryaddressserver_portdncodebaseattrr6   cacepk)r   updater   r
   r'   )r   ldap_objs     r   mainrF      s    98MN7PQ%%0ee4UU+uu-uu-uutUmDUUT6NCUU+UU+UU+M /0M"HMMOr   __main__N)
__future__r   r   r   r/   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Dansible_collections.ieisystem.inmanage.plugins.module_utils.inmanager   r   objectr
   rF   r(   r"   r   r   <module>rP      sW    C BPd>
 5 y6 :( zF r   