Active Directoryを使用してユーザ認証を行う

node

var ActiveDirectory = require('activedirectory');
var config = { url: 'ldap://dc.domain.com',
               baseDN: 'dc=domain, dc=com',
               username: 'username@domain.com',
               password: 'password' }
var ad = new ActiveDirectory(config);

var username = 'username@domain.com';
var password = 'password';

ad.authenticate(username, password, function(err, auth){
  if(err){
    console.log('ERROR: '+JSON.stringify(err));
    return;
  }

  if(auth){
    console.log('Authenticated!');
  }else{
    console.log('Authentication failed!');
  }
});

参照したURL:
https://www.npmjs.com/package/activedirectory

perl

#!/usr/bin/env perl
use Net::LDAP;

$hostname="";
$dn="cn=...,ou=...,dc=...,dc=... ..."; #識別名(DN:Distinguished Name)
$password="";
$ldap=Net::LDAP->new("$hostname") or die "$@";
$message=$ldap->bind($dn,password=>$password);
print "code:".$message->code."\n";
print "error:".$message->error."\n";
print "error_name:".$message->error_name."\n";
print "error_text:".$message->error_text."\n";
print "error_desc:".$message->error_desc."\n";
$ldap->unbind;

$ldap=Net...or die "$@";の後に以下の行を書き忘れていましたので追加しました。
$message=$ldap->bind($dn,password=>$password);
(2012.05.18 追加)


参照したURL:
http://search.cpan.org/~gbarr/perl-ldap-0.43/lib/Net/LDAP.pod
http://search.cpan.org/~gbarr/perl-ldap-0.43/lib/Net/LDAP/Message.pod

c#

using System;
using System.DirectoryServices;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string path = "LDAP://dc=...,dc=...,dc=...,dc=...";

            DirectoryEntry entry = new DirectoryEntry(
                path, "cn=...,ou=...,dc=...,dc=...,dc=...,dc=...", "password");

            try
            { //Bind to the native object to force authentication.
                Object native = entry.NativeObject;
                Console.WriteLine("Authentication Succeeded!");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Authentication Failed:" + ex.Message);
            }
        }
    }
}