Ruby with LDAP or AD

Is there a way of deciding and confirming with facts regarding, which is better and easier to integrate with Ruby. LDAP or ActiveDirectory?

-------------Problems Reply------------

ActiveDirectory is an implementation of the LDAP. You can use the RubyLDAP gem to integrate with AD. I am currently using this gem to connect from a RHEL server to a Windows Domain Controller.

gem install ruby-ldap

I use the net-ldap gem to authenticate and query the ActiveDirectory server at work. It works well. Here's some sample code for verifying a user's login credentials and getting their full name.

def name_for_login( email, password )
email = email[/\A\w+/].downcase # Throw out the domain, if it was there
email << "" # I only check people in my company
ldap =
host: '', # Thankfully this is a standard name
auth: { method: :simple, email: email, password:password }
if ldap.bind
# Yay, the login credentials were valid!
# Get the user's full name and return it
base: "OU=Users,OU=Accounts,DC=mycompany,DC=com",
filter: Net::LDAP::Filter.eq( "mail", email ),
attributes: %w[ displayName ],

The LDAP bindings for Ruby are pretty decent -- not exactly beautiful, but they work well. And, of course, you can access ActiveDirectory as an LDAP server. I have never tried any ActiveDirectory bindings for Ruby.

Category:ruby Views:1 Time:2010-05-19
Tags: ruby ldap

Related post

  • Memory Leak in Ruby net/ldap Module 2010-07-23

    As part of my Rails application, I've written a little importer that sucks in data from our LDAP system and crams it into a User table. Unfortunately, the LDAP-related code leaks huge amounts of memory while iterating over our 32K users, and I haven'

  • Ruby Net:LDAP- NoMethodError for attributes that don't exist 2010-09-09

    I'm doing a simple Net:LDAP search and when I'm outputting an entry's attribute that may not exist for every entry, I get an error "NoMethodError: undefined method 'some_attribute'" Here is the code: require 'rubygems' require 'net/ldap' ldap = Net::

  • Better way to query an LDAP users via ruby net-ldap? 2011-06-22

    Is there a better way to search for users and computers specifically using the Net-ldap gem? Here is what I am currently having to do to get only users. results = search :base => @base, :filter => Net::LDAP::Filter.eq("cn", "*") @results = Arra

  • Ruby - AD/LDAP auth - read user details 2012-03-25

    I am trying LDAP/Active directory authentication. This code is working perfectly, I can authenticate. My question is - How do I retrieve user information from AD? I want to read firstname, lastname, fullname, email etc from AD for the authenticated u

  • How to test if number of entries returned is 0 using ruby net-ldap 2012-04-08

    Building on the search example in this question, how would one use the net-ldap Gem to test whether the search() method returns no results, or some results? --------------Solutions------------- By how it's used in the other question you linked to, it

  • LDAP through Ruby or Rails 2008-12-02

    I've been attempting to hook a Rails application up to ActiveDirectory. I'll be synchronizing data about users between AD and a database, currently MySQL (but may turn into SQL Server or PostgreSQL). I've checked out activedirectory-ruby, and it look

  • What gems should I use to have a Ruby app talk to an LDAP server? 2009-11-06

    My overall goal is to let users of my Rails app authenticate against our organization's ActiveDirectory server over LDAP. (Did I say that right?) I'd like to try the Ruby ActiveLDAP gem. The docs say it depends on either... RubyLDAP or... ruby-net-ld

  • Why would the Net::LDAP gem prevent tests from running? 2009-11-09

    I have installed the ruby-net-ldap gem version 0.0.4 on my OS X (Snow Leopard) system. When I include the line... config.gem('ruby-net-ldap') in environment.rb, my tests won't run and I get this error... Missing these required gems: ruby-net-ldap You

  • Ruby Debug IDE error : ruby-debug-ide-0.4.9/lib/ruby-debug-ide.rb:109:in `debug_load' 2010-06-07

    I hope someone can assist me. I have RubyMine 2.0.2 installed on Windows 7 32 bit computer. Since a week ago (I presume it must have been after I have update some gems) I cant seem to debug form the IDE. I am trying to debug a rake task which I could

  • Querying Active Directory in ruby app on Windows box 2011-02-25

    I have a small ruby app in which I'm trying to query some information from Active Directory. The app will be run by a Windows user who is already logged in. It looks like the ruby-net-ldap gem wants me to connect to an LDAP server using an IP address

  • Ruby on rails 3 Whenever install problem 2011-03-07

    I tried to install whenever for ruby but this keeps on failing. I tried: sudo gem install whenever That properly installed but i can not use the whenever command. I tried to run a "bundle install" but that changend nothing Then i followed a railscast

  • NoMethodError with Devise LDAP and blank User Object Properties 2012-04-30

    I followed these instructions to set up basic LDAP authentication via Devise in my Rails app: A first-time log in with an AD account creates a corresponding user

  • What should I do about this "#version_requirements is deprecated" warning 2010-10-13

    $ ruby -v ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] $ rails -v Rails 2.3.5 Whenever I run script/server I get this warning: => Booting Mongrel => Rails 2.3.5 application starting on ./script/../config/../

  • Upgrading Redmine from 1.0.1 to 1.0.3 2010-11-19

    I did everything from : [email protected]:~/projects/redmine$ cd redmine-1.0.3 [email protected]:~/projects/redmine/redmine-1.0.3$ rake generate_session_store (in /var/www/home/hostin

  • Is it possible to change an AD user account using Ruby LDAP? 2009-03-12

    Using Ruby LDAP running on Linux, I can create a new Active Directory user account without a problem. Now I want to be rename a user account username. When I try to change the sAMAccountName, it doesn't work. Is it possible to change an AD user accou

  • Ruby-LDAP and Snow Leopard 2009-10-16

    When I install Ruby-LDAP on my Snow Leopard box, all appears to go well: $ sudo gem install ruby-ldap Building native extensions. This could take a while... Successfully installed ruby-ldap-0.9.9 1 gem installed Installing ri documentation for ruby-l

  • Using Ruby to access LDAP DIT 2009-10-18

    We use ACLs to grant access to svn repositories. The users/groups are stored in LDAP (openLDAP 2.4 (LDAP3). Does anyone know or used libraries/package (gems) I can use. Basically, I will traverse LDAP DIT and update my svn file based on that. Connect

  • Ruby/LDAP non-ASCII character support 2010-06-29

    It seems like LDAP requires strings with non-ASCII characters to be Base64 encoded. The way to tell it that a string is to be parsed as a base64 encoded string is to add an extra colon to the attribute name such that "cn: name" becomes "cn:: name" (a

  • Java or Groovy based LDAP server as alternative to ruby-ldapserver? 2010-09-30

    A few years ago, I wrote a small LDAP gateway that processes LDAP requests from mail clients (Apple Mail, Thunderbird, SquirrelMail, etc) by looking up the results from a relational database. It's mainly used for email address auto-completion, but ca

Copyright (C), All Rights Reserved.

processed in 0.225 (s). 11 q(s)