Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: K Malo
LDAP usage - beginner [ reply ]  
2009-06-01 23:23
Hi all - thanks in advance for any help you can provide.

I have successfully binded (bound?) to LDAP via the following:

<i>
require 'net/ldap'
SERVER = '[servername]'
PORT = 389
BASE = 'DC=[hostname],DC=com'
DOMAIN = '[domain_name]'
host = '[host_IP]'
user = '[AD|username]'
pass = '[password]'
conn = Net::LDAP.new :host => SERVER,
:port => PORT,
:base => BASE,
:auth => { :username => user,
:password => pass,
:method => :simple }
if conn.bind
puts "you rock"
else
puts "you suck"
end
</i>


"you rock" is returned (conn.bind => true


But now what? I'm not really sure how to pull back any info. For instance, I'd like to see my AD account attributes, but I can't find any usage examples that seem to work. I've tried the following, among others:

<i>
filter = Net::LDAP::Filter.eq( "ou", "[ou_name]" )
attrs = [ "ou" , "objectClass"]

ldap.search( :base => "[dc=host_name], dc=com", :attributes => attrs, :filter =>
filter, :return_result => true ) do |entry|
puts entry.dn
end
</i>


Any ideas to point me in the right direction?