今まで何度も頓挫してたけどようやく形になりそう。


必要なもの

【LDAPサーバー】

ユーザー情報を格納する

パッケージ名:slapd


【LDAPユーティリティ】

LDAPサーバーにいろいろ命令するのに必要

パッケージ名:ldap-utils


【Samba】

NTドメインのドメインコントローラーとして動いてくれる

パッケージ名:samba


【winbind】

Windowsユーザーのuidとgidを自動生成してくれる

パッケージ名:winbind

とりあえずこの辺を使ってWindowsXPがドメインに参加できるところまではできた。




【LDAPサーバー構築】

前回の記事とかぶるけど


/etc/hosts ファイルからベースDNを生成してくれる。


Ubuntu.test.com Ubuntu


と書いておくと「test.com」がベースDNとして設定される。

ちなみにUbuntuはマシン名。

インストール時に自動的に「admin」ユーザーも作られる。


sudo apt-get install slapd



【LDAPユーティリティ】


sudo apt-get install ldap-utils



【Sambaインストール】


sudo apt-get install samba samba-doc



【Sambaスキーマ設定】


Sambaドメインのユーザーとかに必要な情報を持てるようにスキーマをインポート


スキーマのファイルを解凍


sudo cp /usr/share/doc/samba-doc/examples/LDAP/samba.schema.gz /etc/ldap/schema
sudo gzip -d /etc/ldap/schema/samba.schema.gz


変換用ファイル作成


vi schema_convert.conf


中身↓

include /etc/ldap/schema/core.schema
include /etc/ldap/schema/collective.schema
include /etc/ldap/schema/corba.schema
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/duaconf.schema
include /etc/ldap/schema/dyngroup.schema
include /etc/ldap/schema/inetorgperson.schema
include /etc/ldap/schema/java.schema
include /etc/ldap/schema/misc.schema
include /etc/ldap/schema/nis.schema
include /etc/ldap/schema/openldap.schema
include /etc/ldap/schema/ppolicy.schema
include /etc/ldap/schema/ldapns.schema
include /etc/ldap/schema/pmi.schema
include /etc/ldap/schema/samba.schema


作業フォルダ作成


mkdir ldif_output


変換


slapcat -f schema_convert.conf -F ldif_output -n 0 | grep samba,cn=schema

slapcat -f schema_convert.conf -F ldif_output -n 0 -H ldap:///cn={14}samba,cn=schema,cn=config -l cn=samba.ldif


余分なところを削除


vi cn\=samba.ldif


1行目3行目の余分な{14}を削除


ファイル末尾付近の structuralObjectClass: olcSchemaConfig という行以降をすべて削除



スキーマ投入


sudo ldapadd -Q -Y EXTERNAL -H ldapi:/// -f cn\=samba.ldif



【インデックス設定】


vi samba_indices.ldif


中身


dn: olcDatabase={1}hdb,cn=config
changetype: modify
add: olcDbIndex
olcDbIndex: uidNumber eq
olcDbIndex: gidNumber eq
olcDbIndex: loginShell eq
olcDbIndex: uid eq,pres,sub
olcDbIndex: memberUid eq,pres,sub
olcDbIndex: uniqueMember eq,pres
olcDbIndex: sambaSID eq
olcDbIndex: sambaPrimaryGroupSID eq
olcDbIndex: sambaGroupType eq
olcDbIndex: sambaSIDList eq
olcDbIndex: sambaDomainName eq
olcDbIndex: default sub


投入


sudo ldapmodify -Q -Y EXTERNAL -H ldapi:/// -f samba_indices.ldif


ユーザーやグループ情報を格納するところを作る


vi frontend.ldif


中身


dn: ou=users,dc=test,dc=com
objectClass: top
objectClass: organizationalUnit
ou: users

dn: ou=groups,dc=test,dc=com
objectClass: top
objectClass: organizationalUnit
ou: groups

dn: ou=idmap,dc=test,dc=com
objectClass: top
objectClass: organizationalUnit
ou: idmap

dn: ou=computers,dc=test,dc=com
objectClass: top
objectClass: organizationalUnit
ou: computers


投入


sudo ldapadd -x -D cn=admin,dc=test,dc=com -W -f frontend.ldif



【winbindインストール】


sudo apt-get install winbind



【smb.conf 設定】


sudo vi /etc/samba/smb.conf


中身


[global]
dos charset = CP932
unix charset = UTF-8

workgroup = TEST
netbios name = Ubuntu

security = user
passdb backend = ldapsam

os level = 33

domain master = yes
preferred master = yes
local master = yes

domain logons = yes

ldapsam:editposix = yes
ldapsam:trusted = yes

ldap admin dn = cn=admin,dc=test,dc=com
ldap suffix = dc=test,dc=com
ldap group suffix = ou=groups
ldap machine suffix = ou=computers
ldap user suffix = ou=users
ldap ssl = no

idmap config * : backend = ldap
idmap config * : range = 1000000-1999999
idmap config * : ldap_url = ldap://localhost/
idmap config * : ldap_base_dn = ou=idmap,dc=test,dc=com
idmap config * : ldap_user_dn = cn=admin,dc=test,dc=com

ldap delete dn = yes
ldap passwd sync = yes

wins support = yes

template shell = /usr/bash
template homedir = /home/%U

obey pam restrictions = yes

logon home =
logon path =
logon drive = Z:
logon script = logon.cmd

[netlogon]
comment = Network Logon Service
path = /srv/samba/netlogon
guest ok = yes
read only = yes
share modes = no



【ドメイン基本データ投入】


smbd と nmbd を停止させる


sudo service smbd stop

sudo service nmbd stop


パスワードを設定


sudo net idmap secret '*' password

sudo smbpasswd -w password


winbindを再起動


sudo service winbind restart


sudo net sam provision


↑このコマンドが通ればひとまず完成