Skip to content

Instantly share code, notes, and snippets.

@zambon
Created November 24, 2016 17:24
Show Gist options
  • Save zambon/29a7f8851d61481bfc3b9d174d489b91 to your computer and use it in GitHub Desktop.
Save zambon/29a7f8851d61481bfc3b9d174d489b91 to your computer and use it in GitHub Desktop.
Connect to LDAP using TLS
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()
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