Created
November 24, 2016 17:24
-
-
Save zambon/29a7f8851d61481bfc3b9d174d489b91 to your computer and use it in GitHub Desktop.
Connect to LDAP using TLS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ldap | |
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER) | |
ldapconn = ldap.initialize('ldaps://...:636') | |
ldapconn.set_option(ldap.OPT_X_TLS_CIPHER_SUITE, 'TLSv1') | |
ldapconn.simple_bind_s('...', '...') | |
ldapconn.unbind_s() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "net/ldap" | |
ldap = Net::LDAP.new( | |
host: "...", | |
port: 636, | |
encryption: :simple_tls, | |
auth: { | |
method: :simple, | |
username: "...", | |
password: "..." | |
} | |
) | |
ldap.bind |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment