Created
July 19, 2018 15:14
-
-
Save renanregis/49eb433968808bbb64c2d7551a5d7ac8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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' | |
class LdapService | |
def con | |
@ldap = Net::LDAP.new | |
@ldap.host = '172.22.0.10' | |
@ldap.port = 389 | |
@ldap.auth "CN=SSO,OU=SISTEMAS,OU=Users,OU=Desenvolvimento,OU=GEINF,OU=CRE,OU=SEFIN,DC=sefin,DC=ro,DC=gov,DC=br", "password" | |
arr = [] | |
if @ldap.bind | |
filter = "(&(objectClass=user)(sAMAccountName=))" | |
treebase = "OU=distribution, OU=GEINF,OU=CRE,OU=SEFIN,DC=sefin,DC=ro,DC=gov,DC=br" | |
@ldap.search(:base => treebase, :filter => filter) do |item| | |
arr << item.cn | |
end | |
@ldap = {:usuarios => arr} | |
else | |
@ldap.get_operation_result | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment