Guest User

Untitled

a guest
Jul 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. require 'net/ldap'
  2.  
  3. class LdapService
  4.  
  5. def con
  6.  
  7. @ldap = Net::LDAP.new
  8. @ldap.host = '172.22.0.10'
  9. @ldap.port = 389
  10. @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"
  11.  
  12. arr = []
  13. if @ldap.bind
  14. filter = "(&(objectClass=user)(sAMAccountName=))"
  15. treebase = "OU=distribution, OU=GEINF,OU=CRE,OU=SEFIN,DC=sefin,DC=ro,DC=gov,DC=br"
  16. @ldap.search(:base => treebase, :filter => filter) do |item|
  17. arr << item.cn
  18. end
  19. @ldap = {:usuarios => arr}
  20. else
  21. @ldap.get_operation_result
  22. end
  23. end
  24. end
Add Comment
Please, Sign In to add comment