カテゴリー: OpenLdap
OpenLdapにLINUXユーザーアカウントを作ったけどその他の情報もLDAPに入れておきたかったので作ったSchema
/etc/openldap/schema フォルダーに ldapusers.schema を作成した。
[text]
attributetype ( 1.1.2.1.1.500.1
	NAME ‘userName’
	DESC ‘jp.compsys user name UTF8’
	EQUALITY caseIgnoreMatch
	SUBSTR caseIgnoreSubstringsMatch        <—- filter の部分文字列検索するためには必要か?!
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{200} )
attributetype ( 1.1.2.1.1.500.2
	NAME 'mailAddress'
	DESC 'jp.compsys email address'
	EQUALITY caseIgnoreIA5Match
	SUBSTR caseIgnoreSubstringsMatch
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
attributetype ( 1.1.2.1.1.500.3
	NAME 'mailAddressMobile'
	DESC 'jp.compsys mobile email address'
	EQUALITY caseIgnoreIA5Match
	SUBSTR caseIgnoreSubstringsMatch
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
objectclass ( 1.1.2.1.1.100.1
	NAME 'personalInfo'
	DESC 'jp.compsys personal information'
	SUP top AUXILIARY
	MAY	( userName $ mailAddress $ mailAddressMobile ) )
[/text]
/etc/openldap/slapd.conf にldapusers.schema を追加する。修正したら slapd を再起動する。
[text]
include		/etc/openldap/schema/nis.schema
include		/etc/openldap/schema/openldap.schema
include		/etc/openldap/schema/ppolicy.schema
include		/etc/openldap/schema/collective.schema
include		/etc/openldap/schema/ldapusers.schema    <—–ここ
[/text]
javaで使うときは
[text]
 // objectClass(必須)
 Attribute attrObjClass = new BasicAttribute(“objectClass”);
 attrObjClass.add(0, “top”);
 attrObjClass.add(1, “account”);
 attrObjClass.add(2, “posixAccount”);
 attrObjClass.add(3, “personalInfo”);
 attrs.put(attrObjClass);
[/text]
OpenLdapでメールアカウントを作る場合の dovecot の設定 mbox とmail_locationの設定
OpenLdapでメールアカウントを作る場合はhomeディレクトリを作成しない。
じゃあどこにメールを置くの?
メール自身は/var/spool/mail でよいがdovecotのmboxはどうすんの?ということで書いておきます。
まずmbox用フォルダーの作成
[text]
mkdir /var/spool/mbox
chmod 777 /var/spool/mbox
[/text]
10-mail.confの編集
[text]
mail_location = mbox:/var/spool/mbox/%u:INBOX=/var/spool/mail/%u
[/text]
これでよし!
CentOS6 OpenLDAPサーバで認証する。TLS接続しない場合
パッケージのインストールを行います。
[text]
# yum -y install openldap-servers
# yum -y install openldap-clients
[/text]
基本的なファイルを用意する。
[text]
# rm -rf /etc/openldap/slapd.d
# rm -rf /var/lib/ldap/*
# cp /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf
[/text]
confファイルを編集する。
[text]
vi /etc/openldap/slapd.conf
[/text]
内容を修正
OPenLdapに接続するときのパスワードはとりあえず secret にする。後でかえた方がいい
[text]
suffix          “dc=hogehoge,dc=com”
rootdn          “cn=manager,dc=hogehoge,dc=com”
rootpw          secret
[/text]
OS起動時にOpenLDAPを起動するようにする。
OpenLDAPを起動する。
[text]
# chkconfig slapd on
# /etc/init.d/slapd start
[/text]
動いているかを確認する。OKならばよい。
[text]
# ldapsearch -x -D “cn=manager,dc=hogehoge,dc=com” -w secret
[/text]
ベースとなるDNを作成するためLDIFファイルを作成する。
[text]
# cat schema.ldif
dn: dc=hogehoge,dc=com
objectClass: dcObject
objectClass: organization
dc: hogehoge
o: hogehoge
dn: ou=users,dc=hogehoge,dc=com
objectclass: organizationalUnit
ou: users
dn: ou=groups,dc=hogehoge,dc=com
objectclass: organizationalUnit
ou: groups
[/text]
LDIFファイルをLDAPサーバにインポートする。
[text]
# ldapadd -x -D “cn=manager,dc=hogehoge,dc=com” -w secret -f schema.ldif
[/text]
LINUX をTSLなしでLDAP認証にするにはsssdを削除しておく。SSSDを使いたい場合はTLSの設定が必要。
[text]
# yum -y erase sssd
[/text]
必要なパッケージを追加
[text]
# yum -y install pam_ldap nss-pam-ldapd
[/text]
authconfig-tui コマンドでLDAP認証の設定をする
[text]
最初のページで以下のように設定
LDAPを使用
LDAP認証を使用
次のページで以下のように設定する
TLSを使用にはチェックをいれない
サーバー :ldap://127.0.0.1/
ベースDN :dc=hogehoge,dc=com
[/text]
これで十分使える。
 2月 7th, 2013 |
2月 7th, 2013 |  Author:
Author:  Posted in
Posted in 