Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use Ldap3 Library

Shulou Source: shulou.com Published: 2022-06-02 00:53:08 09月15日 Update

Today, I would like to talk to you about the use of the Ldap3 library, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

Ldap3 library

Ldap3 is a pure Python LDAP management library.

Project address: (https://github.com/cannatag/ldap3)

Guidance document: http://ldap3.readthedocs.org

Working with scen

Generally, our company will use the account password system, such as the AD server of Windows and the OpenLdap account system under Linux system.

By default, we all maintain accounts and passwords through AD or OpenLDAP management. But we hope that through the program to automatically manage the account, docking the personnel system, the account can automatically add or decrease and change the password.

Using tutorials

Install ldap3

Premise:

Install python3 and pip3 correctly first

Installation:

1pip install ldap3

Test results:

In the python environment, execute

1import ldap3

It can be imported normally, which means the installation is successful.

Basic functions of ldap3

Connect to the server:

1234567891011121314151617181920from ldap3 import Server, Connection, NTLMdef test (): # encrypted connection AD server server1 = Server ("xxx.xxx.xxx.xxx", port=636, use_ssl=True, get_info=ALL, connect_timeout=5) # unencrypted connection AD server server2 = Server ("xxx.xxx.xxx.xxx", get_info=ALL, connect_timeout=5) conn = Connection (# configure server connection parameter server = server1, # if the encrypted connection uses server1 Unencrypted connections use server2 auto_bind = True, authentication = NTLM, # connection Windows AD needs to be configured, if you connect to OpenLDAP, do not configure read_only = False, # to AD read-only configuration To modify the data: configure True user = username,# administrator account password = password corresponding to password,# administrator account fast_decoder=True, check_names=True,) return conn.userif _ _ name__ = ='_ _ main__': print (test ())

If you can correctly output the administrator account information of the connection server, that is, the connection is successful

After reading the above, do you have any further understanding of how to use the Ldap3 library? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Server service administration account configuration password system encryption content administrator account usage method success personnel information company premise function parameter Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Information Huawei NVidia Docker