Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Ldap3 Library

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report