Hi ,
Anyone suggest me that how to get ad user from active directory using secure ldap.
Hi ,
Anyone suggest me that how to get ad user from active directory using secure ldap.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mohammad HussainRank #513 · 4.8K reputationPosted Jul 26, 2023, 6:58 AM EDT
import ssl from ldap3 import Server, Connection, SUBTREE # LDAP server settings ldap_server = 'ldaps://your_ldap_server:636' ldap_user = 'username' # Replace with your LDAP username ldap_password = 'password' # Replace with your LDAP password # Search settings base_dn = 'dc=your_domain,dc=com' search_filter = '(sAMAccountName=user_to_find)' # SSL context ssl_context = ssl.create_default_context(cafile='path_to_trusted_root_certificate.pem') # Create an LDAP connection server = Server(ldap_server, use_ssl=True, get_info=Connection.ALL, ssl_context=ssl_context) conn = Connection(server, user=ldap_user, password=ldap_password) # Bind to the LDAP server if not conn.bind(): print('Failed to bind:', conn.result) else: # Search for the user conn.search(search_base=base_dn, search_filter=search_filter, search_scope=SUBTREE, attributes=['sAMAccountName', 'mail', 'displayName']) # Print user attributes for entry in conn.entries: print('Username:', entry.sAMAccountName) print('Email:', entry.mail) print('Display Name:', entry.displayName) # Close the connection conn.unbind()Rajan KumarRank #4,480 · 341 reputationPosted Jul 26, 2023, 7:45 AM EDT
Anyone suggest me that how to get ad user from active directory using secure ldap in c#.