O'Reilly logo

Python Network Programming Cookbook - Second Edition by Dr. M. O. Faruque Sarker, Pradeeban Kathiravelu

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

We will use the ldap3 library and import Server, Connection, and ALL modules from it. ldap3 offers an object-oriented access to the directory servers of LDAP.

Listing 11.6 connects to a remote LDAP server and retrieves the server information and schema as follows:

#!/usr/bin/env python 
# Python Network Programming Cookbook, Second Edition   -- Chapter - 11 
# This program is optimized for Python 2.7.12 and  Python 3.5.2. 
# It may run on any other version with/without  modifications. 
 
import argparse 
from ldap3 import Server, Connection, ALL 
 
 
def main(address): 
    # Create the Server object with the given address. 
    # Get ALL information. 
    server = Server(address, get_info=ALL) 
    #Create a connection object, and bind with auto bind set ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required