From: Francis Cianfrocca Date: 2007-09-27T03:30:52+09:00 Subject: Re: active directory ------=_Part_3978_6404739.1190831446548 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 9/26/07, Arlen Christian Mart Cuss wrote: > > > On Tue, 2007-09-25 at 04:06 +0900, Martin DeMello wrote: > > > Is there any ruby library that will let me authenticate against an > > active directory server from a linux machine? I looked through the AD > > gems but the documentation assumed that I knew what I was doing > > already, and *seemed* to imply that I needed to be running this from a > > windows box sitting in a windows domain. > > > > I recently had this problem. Some users have found Net::LDAP simpler because it doesn't require the installation of an outboard LDAP library. Here's how the equivalent solution might look in Net::LDAP (as you said, "your schema may vary"): require 'rubygems' require 'net/ldap' ldap = Net::LDAP.new ldap.host = your_server_ip_address ldap.port = your_server_port # typically 389 or 3268 for A/D ldap.auth "CN=John Smith,CN=Users,dc=yourcompany,dc=com", "a-password" ldap.search( :filter=>"sAMAccountName=John Smith", :attributes=>[:memberOf], :base=>"cn=Users,dc=yourcompany,dc=com", ) {|entry| p entry[:memberof] } ------=_Part_3978_6404739.1190831446548--