Skip to content
Create a gist now

Instantly share code, notes, and snippets.

require 'sinatra'
require 'net/ldap'
ldap = = ''
ldap.port = 389
ldap.auth "username", "password"
get '/people/:id' do
filter = Net::LDAP::Filter.eq('cn', params[:id] + '*')
treebase = "dc=reputablecompany, dc=com" => treebase, :filter => filter) do |entry|
puts "CN: #{}"
if entry.respond_to?("company")
puts "Department: #{}"
p ldap.get_operation_result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.