前回、AjaXplorer のインストールを行ったので、今回はAjaXplorer で ActiveDirectory を使うための設定を行います。
1.php_ldap.dll を使用しますので、まずは「extension=php_ldap.dll」のコメントを解除します。
2.server/conf/conf.php を修正します。
LDAP認証プラグインを使うように「$AUTH_DRIVER」を変更します(※定義内容は、plugins/auth.ldap/manifest.xml で確認できます)。
$AUTH_DRIVER = array(
"NAME" => "ldap",
"OPTIONS" => array(
"LDAP_URL" => 'LDAP://gine.jp',
"LDAP_PORT" => '389',
"LDAP_USER" => 'admin@gine.jp',
"LDAP_PASSWORD" => 'password',
"LDAP_DN" => 'OU=Tokyo,DC=gine,DC=jp',
"LOGIN_REDIRECT" => false,
"AUTOCREATE_AJXPUSER" => false,
"LDAP_FILTER" => '(&(objectCategory=Person)(objectClass=User))',
"TRANSMIT_CLEAR_PASS" => true)
);
※上記例ではパスワードが平文で流れますのでご注意ください。
adminのパスワードを変更するようにダイアログが表示されるので「ADMIN_PASSWORD」も修正しておきます。
define("ADMIN_PASSWORD", "password");
3.plugins/auth.ldap/class.ldapAuthDriver.php を修正します。修正箇所は3箇所です。
[1] ldap_set_optionを追加します。
function LDAP_Connect(){
$ldapconn = ldap_connect($this->ldapUrl, $this->ldapPort)
or die("Cannot connect to LDAP server");
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
・・・・・
[2] uid を samaccountname に変更します。
function listUsers(){
・・・・・
foreach($entries as $id => $person){
$persons[$person['samaccountname'][0]] = "XXX";
}
・・・・・
}
[3] uid を samaccountname に、dn を userprincipalname に変更します。
function checkPassword($login, $pass, $seed){
$ret = ldap_search($this->ldapconn,$this->ldapDN,"samaccountname=".$login);
$entries = ldap_get_entries($this->ldapconn, $ret);
if ($entries['count']>0) {
if (@ldap_bind($this->ldapconn,$entries[0]["userprincipalname"][0],$pass)) {
・・・・・
}
※samaccountnameやuserprincipalnameは全て小文字の必要があります。
上記で完了です。AjaXplorerにアクセスするとADのユーザーやパスワードを使ってログインできます。