Native Ruby Access to Microsoft Active Directory
Pull request Compare This branch is 104 commits ahead of keithpitty:master.
Latest commit a997c31 May 4, 2015 @ajrkerr Merge pull request #15 from Mazwak/PR-1-Learning-git
Various patches reworked in a branch

= Active Directory

Ruby Integration with Microsoft's Active Directory system based on original code by Justin Mecham and James Hunt at

See documentation on ActiveDirectory::Base for more information.

Caching: Queries for membership and group membership are based on the distinguished name of objects. Doing a lot of queries, especially for a Rails app, is a sizable slowdown. To alleviate the problem, I've implemented a very basic cache for queries which search by :distinguishedname. This is disabled by default. All other queries are unaffected.

A code example is worth a thousand words:

require 'rubygems'
require 'active_directory'

# Uses the same settings as net/ldap
settings = {
	:host => 'domain-controller.example.local',
	:base => 'dc=example,dc=local',
	:port => 636,
	:encryption => :simple_tls,
	:auth => {
	  :method => :simple,
	  :username => "username",
	  :password => "password"

# Basic usage

ActiveDirectory::User.find(:first, :userprincipalname => "")


#Caching is disabled by default, to enable: