Hi Kouhei,
I know you from the ActiveLdap list and probably should have asked my question there first.
My AD server requires secure LDAP so I have to use 636.
ad.rb<<<
require 'myconstants'
class AdUser < ActiveLdap::Base
ldap_mapping :dn_attribute => 'sAMAccountName', :prefix => 'dc=ad',
:classes => ['top','person','user']
end
class AdGroup < ActiveLdap::Base
ldap_mapping :dn_attribute => 'cn', :prefix => '',
:classes => ['top','group']
end
ActiveLdap::Base.establish_connection(:host => 'ldap.dom.edu',
:port => 636,
:base => 'dc=dom,dc=edu',
:bind_dn => AdAdmin,
:password => AdPW,
:allow_anonymous => false )
# Retrieve all users with some attribute
def ad_user_search(attribute, value, returns)
AdUser.find(
:all,
:attribute => attribute,
:value => value,
:attributes => returns
)
end
test.rb<<<
#!/usr/local/bin/ruby
# NOTE...RUBY TIME CLASS MAY BE FASTER THAN DATE CLASS???
$LOAD_PATH << '../dom_ruby_libs'
require 'rubygems'
require 'active_ldap'
require 'ad'
require 'myconstants'
puts "===AD==="
ad_user = ad_user_search('sAMAccountName', 'myusername', ['cn','sn'])
ad_user.each do |user|
puts user.inspect
end
路路路
----- Original Message -----
From: "Kouhei Sutou" <kou@cozmixng.org>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Friday, November 14, 2008 8:59:48 PM GMT -06:00 US/Canada Central
Subject: Re: Active Directory access - not just users, but computers too
Hi,
In <93821991.1744261226699370463.JavaMail.root@zcs10>
"Re: Active Directory access - not just users, but computers too" on Sat, 15 Nov 2008 06:47:09 +0900,
Matt Mencel <MR-Mencel@wiu.edu> wrote:
Any chance you would be willing to share the code you used to access AD via LDAP? I've tried the ActiveLdap and ActiveDirectory gems and so far have not had any success.
Please show the detail for the ActiveLdap try.
I'm one of the ActiveLdap developers.
Thanks,
--
kou