LDAP
Oct 02, 2008
PostgreSQLの認証をLDAPでする
むずかしい話でもなくて。
host all all 127.0.0.1/32 ldap "ldap://192.168.1.1/dc=example,dc=org;uid=;,ou=Users,dc=example,dc=org"
とpg_hba.confに書く。
ldap://ldaphost/basedn;prefix;suffixとなる。この例でユーザーがhogeならばuid=hoge,ou=Users,dc=example,dc=jpが使われる。
ちなみに認証だけなのでユーザーの作成はcreateuserで別に作っておくように。AuthenticationとAuthorizationは違うという話。
Feb 25, 2008
LDAP Account Manager 2.2.0
気付いたところ。
- ユーザー一覧表示のときにGIDからグループ名に変換するかどうかを設定で決められるようになった。今まではログインするたびにチェックボックスにチェックを入れる必要があった。
- グループ一覧のときのプライマリグループの表示についても設定になる。
- ユーザ追加画面のIFが変わった。他いろいろUIの改善。
- ログ回りの設定がファイルからGUIに移動
Dec 09, 2007
luma
gui utility for accessing and managing LDAP database
qtを使ったLDAPブラウザ。わりといい感じ。
Nov 21, 2007
gforge + LDAP
gforgeでLDAP認証をする。ldapextauth pluginを使用する。
このプラグインは on the fly でユーザーを作成する。
- gforge-plugins-extra を入れる。
- /etc/gforge/plugins/dapextauth/config.php mapping.phpを作る。svnから持ってきてカスタマイズ
- /usr/share/gforge/plugins/ldapextauth/bin/db-upgrade.pl
- /usr/lib/gforge/bin/register-plugin ldapextauth "LDAP external authentication"
- これでpluginは登録される。
- libnss-ldapとまぜると危険。getentでユーザーチェックをしているのでそっちで発見されると拒否される。
Oct 17, 2007
MediaWiki+LDAP
MediaWikiの認証にLDAPを組み合わせる。
- おっかしーなーと思ったらphp-ldapを入れてなかった。アホすぎる。
- http://www.mediawiki.org/wiki/Extension:LDAP_Authentication
- LdapAuthentication.phpをダウンロードしてextensionsに起く
require_once( "$IP/extensions/LdapAuthentication.php" );
$wgAuth = new LdapAuthenticationPlugin();
$wgLDAPDomainNames = array(
"testLDAPdomain"
);
$wgLDAPServerNames = array(
"testLDAPdomain"=>"192.168.1.1"
);
$wgLDAPUseLocal = false;
$wgLDAPEncryptionType = array(
"testLDAPdomain"=>"clear"
);
$wgLDAPSearchStrings = array(
"testLDAPdomain"=>"uid=USER-NAME,ou=Users,dc=example,dc=net"
)
LocalSettings.phpに書く。USER-NAMEがログインIDに置換される。
- WikiSysopに入れなくなるのでどうするか。WikiSysopをLDAPに作るのもいいが、一旦LDAPを外して通常のログインで入ってからLDAPのユーザーに権限を与える方法で解決させた。
Jul 15, 2007
OpenDS-1.0.0
OpendSの1.0.0-build001が7/14にリリースされた。
インストールはさらに簡単になっていてウィザードに従ってやればできる。さらに重要なのがレプリケーションに関して。これもウィザードの指示でホストとかポートを指定してやるだけでレプリケーションができる。ここまで簡単ならOpen LDAPから移行することを本気で考えようか。
Jun 09, 2007
djangoでLDAP認証
djangoでLDAP認証する方法
Django's new authentication backends という記事もあるのだが、これではanonymousでできないのでちょっと改良。anonymousでbindしてdnを捜して、そのdnで認証するという手順。手順は普通の話。
import ldap
import ldap
from django.contrib.auth.models import User
# Constants
AUTH_LDAP_SERVER = '192.168.0.1'
class LDAPBackend:
def authenticate(self, username=None, password=None):
base = "ou=Users,dc=example,dc=jp"
scope = ldap.SCOPE_SUBTREE
filter = "(&(objectclass=person) (uid=%s))" % username
ret = ['dn']
# Authenticate the base user so we can search
try:
l = ldap.open(AUTH_LDAP_SERVER)
l.protocol_version = ldap.VERSION3
except ldap.LDAPError:
return None
try:
result_id = l.search(base, scope, filter, ret)
result_type, result_data = l.result(result_id, 0)
# print result_data
if (len(result_data) != 1):
return None
# Attempt to bind to the user's DN
l.simple_bind_s(result_data[0][0],password)
try:
user = User.objects.get(username__exact=username)
except:
# Theoretical backdoor could be input right here. We don't
# want that, so input an unused random password here.
# The reason this is a backdoor is because we create a
# User object for LDAP users so we can get permissions,
# however we -don't- want them able to login without
# going through LDAP with this user. So we effectively
# disable their non-LDAP login ability by setting it to a
# random password that is not given to them. In this way,
# static users that don't go through ldap can still login
# properly, and LDAP users still have a User object.
from random import choice
import string
temp_pass = ""
for i in range(8):
temp_pass = temp_pass + choice(string.letters)
user = User.objects.create_user(username,
username + '@example.jp',temp_pass)
user.is_staff = False
user.save()
# Success.
return user
except ldap.INVALID_CREDENTIALS:
# Name or password were bad. Fail.
return None
def get_user(self, user_id):
try:
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None
ほんのちょっとだけ変更してあります。
May 12, 2007
PAM+LDAP
LDAPを使ってLinuxのPAM認証を導入する手順メモ
- libnss-ldap libpam-ldapをインストール
- ldapサーバーの指定とかはdebconfに適当に返答する。
- libnss-ldapに関してはnssswitch.confを手動で書き換え。
- /etc/pam.d/common-authを書き換え。/usr/share/doc/libpam-ldap/README.Debianを読むこと。
- libnss-ldap.confにhost ldap://192.168.0.1/とか書くとなぜか見てくれない。 host 192.168.0.1にしないと駄目だった。
proftpd + PAM + LDAP
結論としては駄目ということなんだろうか。
mod_ldapの設定は以下。
LDAPServer localhost
LDAPDoAuth on "ou=Users,dc=example,dc=com"
Apr 30, 2007
OpenDSにログインできなくなった
LDAP StudioのテストとしてOpenDSを使おうとしたが。
結局はconfig.ldifの書き直しのようだ。 ./bin/encode-password -s SSHA512 -c 'newpassword'を実行して、出力をconfig.ldifの
dn: cn=Directory Manager,cn=Root DNs,cn=config の userpassword: を書き直せばいいようだ。
Apr 29, 2007
LDAP Studio 0.7.0
リリースされていた。
apacheds-1.5.0を使ってみる
いつのまにか(4/12)にリリースされていた。
# java -jar apacheds-1.5.0-linux-i386-setup.jar
を実行する。適当にウィザードに答える。管理者がuid=admin,ou=systemになっていた。間違えてメモしていたかな。conf/server.xmlに設定が書いてあるので気にいらなかったら変更する。
Multi-Master replicationが実装されたそうなので、そのうち試してみることにする。
Mar 24, 2007
DSML
LDAP Studioを使っていたら、import/exportにDSMLという文字が。
ApacheDSを使ってみる
Apacheで開発されているDirectory Server(LDAP サーバ)のApacheDS-1.0.1を使ってみる。
# java -jar apacheds-1.0.1-linux-i386-setup.jarを実行する。
初期状態でTCP/10389を使って、uid=admin,dc=system・password=secretで管理者権限でbind。
普通にLDAPサーバとして使える。残念ながらMulti-MasterではないのでOpenLDAPから移行する元気はない。
でもOpenLDAPよりはましなんだろうなあとは思う。
LDAP Studio
Apache Directoryで開発されているLDAP Studioを使ってみる。




