Diferenças
Aqui você vê as diferenças entre duas revisões dessa página.
Próxima revisão | Revisão anterior | ||
dgti:activedirectory:testeconexaosuap [2017/03/28 15:35] 127.0.0.1 Edição externa |
— (atual) | ||
---|---|---|---|
Linha 1: | Linha 1: | ||
- | [[sistemas: | ||
- | ====== Teste de Conexão com o AD a partir do Servidor SUAP ====== | ||
- | |||
- | Instale o pacote python-ldap | ||
- | |||
- | < | ||
- | sudo apt-get install python-ldap | ||
- | </ | ||
- | |||
- | Acesse o servidor do SUAP e crie o arquivo conexao.py com o código abaixo. | ||
- | Em seguida execute usando o comando | ||
- | |||
- | < | ||
- | |||
- | ==== Sem SSL ==== | ||
- | |||
- | <code python conexao.py> | ||
- | |||
- | # | ||
- | import ldap | ||
- | import sys | ||
- | import socket | ||
- | import ssl | ||
- | socket.ssl | ||
- | |||
- | host = ' | ||
- | ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, | ||
- | ldapmodule_trace_level = 1 | ||
- | ldapmodule_trace_file = sys.stderr | ||
- | l = ldap.initialize(host, | ||
- | l.set_option(ldap.OPT_REFERRALS, | ||
- | l.set_option(ldap.OPT_PROTOCOL_VERSION, | ||
- | l.set_option(ldap.OPT_X_TLS, | ||
- | l.set_option( ldap.OPT_X_TLS_DEMAND, | ||
- | ldap.set_option(ldap.OPT_DEBUG_LEVEL, | ||
- | if l.simple_bind(" | ||
- | print " | ||
- | </ | ||
- | |||
- | ==== Com SSL ==== | ||
- | |||
- | <code python conexao.py> | ||
- | |||
- | # | ||
- | import ldap | ||
- | import sys | ||
- | import socket | ||
- | import ssl | ||
- | socket.ssl | ||
- | |||
- | host = ' | ||
- | ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, | ||
- | ldapmodule_trace_level = 1 | ||
- | ldapmodule_trace_file = sys.stderr | ||
- | l = ldap.initialize(host, | ||
- | l.set_option(ldap.OPT_REFERRALS, | ||
- | l.set_option(ldap.OPT_PROTOCOL_VERSION, | ||
- | l.set_option(ldap.OPT_X_TLS, | ||
- | l.set_option( ldap.OPT_X_TLS_DEMAND, | ||
- | ldap.set_option(ldap.OPT_DEBUG_LEVEL, | ||
- | if l.simple_bind_s(" | ||
- | print " | ||
- | </ | ||
- | |||
- | ----------- | ||
- | <WRAP rightalign> | ||
- | Última revisão: ~~LASTMOD~~ | ||
- | </ |