{"id":7823,"library":"types-ldap3","title":"Typing Stubs for ldap3","description":"types-ldap3 provides type hinting stubs for the popular `ldap3` library, enabling static type checkers like MyPy to validate `ldap3` code. It is part of the Python typeshed project, ensuring up-to-date and high-quality type definitions. This package does not provide any runtime functionality itself but enhances developer experience by catching type-related errors early. It is actively maintained and updated regularly as part of typeshed.","status":"active","version":"2.9.13.20260408","language":"python","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","ldap","mypy","typeshed"],"install":[{"cmd":"pip install types-ldap3 ldap3","lang":"bash","label":"Install with ldap3"},{"cmd":"pip install types-ldap3","lang":"bash","label":"Install stubs only"}],"dependencies":[{"reason":"This package provides type stubs for the `ldap3` library; `ldap3` itself is required for runtime functionality.","package":"ldap3","optional":false}],"imports":[{"note":"`types-ldap3` does not provide any runtime imports; it only adds type information to the `ldap3` library. All imports should be directly from `ldap3`.","symbol":"Server, Connection","correct":"from ldap3 import Server, Connection"}],"quickstart":{"code":"import os\nfrom ldap3 import Server, Connection, AUTH_SIMPLE, STRATEGY_SYNC\n\n# Configure LDAP connection details (replace with your server/credentials)\nLDAP_SERVER = os.environ.get('LDAP_SERVER', 'ldap.forumsys.com') # Example public LDAP server\nLDAP_PORT = int(os.environ.get('LDAP_PORT', '389'))\nLDAP_USER = os.environ.get('LDAP_USER', 'cn=read-only-admin,dc=example,dc=com')\nLDAP_PASSWORD = os.environ.get('LDAP_PASSWORD', 'password')\n\ntry:\n    # Initialize LDAP server and connection\n    server = Server(LDAP_SERVER, port=LDAP_PORT)\n    conn = Connection(server,\n                      user=LDAP_USER,\n                      password=LDAP_PASSWORD,\n                      authentication=AUTH_SIMPLE,\n                      strategy=STRATEGY_SYNC)\n\n    # Bind to the server\n    if not conn.bind():\n        print(f\"LDAP bind failed: {conn.result}\")\n        exit(1)\n\n    print(f\"Successfully connected to LDAP server: {LDAP_SERVER}\")\n\n    # Example: Perform a search operation\n    search_base = 'dc=example,dc=com'\n    search_filter = '(objectClass=person)'\n    conn.search(search_base, search_filter, attributes=['cn', 'mail'])\n\n    print(f\"Found {len(conn.entries)} entries:\")\n    for entry in conn.entries:\n        print(f\"  CN: {entry.cn}, Mail: {entry.mail}\")\n\n    # Unbind from the server\n    conn.unbind()\n    print(\"Connection unbound.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates a basic LDAP connection and search using the `ldap3` library. By installing `types-ldap3`, type checkers like MyPy can now provide accurate type suggestions and detect errors in this code, enhancing development quality without changing the runtime behavior."},"warnings":[{"fix":"Ensure `ldap3` is installed via `pip install ldap3` in addition to `pip install types-ldap3`.","message":"`types-ldap3` provides only type stubs and no runtime functionality. You must install the actual `ldap3` library for your application to run.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ideally, use the `types-ldap3` version that most closely corresponds to your `ldap3` version. `typeshed` aims to keep stubs up-to-date with recent `ldap3` releases. If issues persist, check the `typeshed` GitHub for specific version compatibility notes or `ldap3` changelogs.","message":"Type checking issues can arise if the version of `types-ldap3` does not match the installed `ldap3` library version, especially after significant API changes in `ldap3`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install the `ldap3` library: `pip install ldap3`.","message":"Installing `types-ldap3` alone will not resolve `ModuleNotFoundError: No module named 'ldap3'` at runtime. Stubs are for static analysis, not runtime dependencies.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'activ':68 'catch':60 'checker':20 'code':26 'date':39 'definit':45 'develop':57 'earli':65 'enabl':17 'enhanc':56 'ensur':35 'error':64 'experi':58 'function':53 'high':42 'high-qual':41 'hint':10 'ldap':79 'ldap3':4,7,15,25 'librari':16 'like':21 'maintain':69 'mypi':22,80 'packag':47 'part':29,74 'popular':14 'project':34 'provid':8,50 'python':32 'qualiti':43 'regular':72 'relat':63 'runtim':52 'static':18 'stub':2,11,78 'type':1,6,9,19,44,62,77 'type-rel':61 'types-ldap3':5 'typesh':33,76,81 'up-to-d':36 'updat':71 'valid':24","created_at":"2026-04-16T14:14:55.552253+00:00","updated_at":"2026-04-16T14:14:55.552253+00:00","problems":{"verify_error":"error: Failed to parse: `types-ldap3 ldap3`\n  Caused by: Expected one of `@`, `(`, `<`, `=`, `>`, `~`, `!`, `;`, found `l`\ntypes-ldap3 ldap3\n            ^"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.9.13.20260518","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/typeshed-internal/stub_uploader","docs":null,"changelog":"https://github.com/typeshed-internal/stub_uploader/blob/main/data/changelogs/ldap3.md","pypi":"https://pypi.org/project/types-ldap3/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["type-stubs"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"install_fail","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-05","install_tag":null}}