ラベル Active Directory の投稿を表示しています。 すべての投稿を表示
ラベル Active Directory の投稿を表示しています。 すべての投稿を表示

2013年3月9日土曜日

SubversionのBasic認証にActive Directoryを利用


SubversionのBasic認証にActive Directoryを利用する方法です。
Active Directoryに登録しているユーザの詳細は前回記事を参照ください。

【ADサーバ】
OS: Windows Server 2008 R2(64-bit)
Domain Name: kuitan.net
IP: 192.168.77.125
⇒AD登録ユーザ:
 dn: CN=aduser01,CN=Users,DC=kuitan,DC=net
 dn: CN=puser01,OU=person,DC=kuitan,DC=net

【Webサーバ】
OS: CentOS 6.3(64-bit)
Apache: 2.2.15
Subversion: 1.6.11
IP: 192.168.77.147


■SVNリポジトリ作成
[root@web03 ~]# mkdir /opt/svn [root@web03 ~]# mkdir /opt/svn/users [root@web03 ~]# mkdir /opt/svn/person [root@web03 ~]# svnadmin create /opt/svn/users/project01 [root@web03 ~]# svnadmin create /opt/svn/users/project02 [root@web03 ~]# svnadmin create /opt/svn/person/project03 [root@web03 ~]# svnadmin create /opt/svn/person/project04 [root@web03 ~]# chown -R apache: /opt/svn

■subversion.conf追加設定
[root@web03 ~]# vi /etc/httpd/conf.d/subversion.conf [root@web03 ~]# tail -27 /etc/httpd/conf.d/subversion.conf <Location /users> DAV svn SVNListParentPath on SVNParentPath /opt/svn/users AuthType Basic AuthName "Subversion Authentication Users" AuthBasicProvider ldap AuthzLDAPAuthoritative off AuthLDAPURL ldap://192.168.77.125:389/cn=users,dc=kuitan,dc=net?sAMAccountName?sub?(objectClass=*) AuthLDAPBindDN Administrator@kuitan.net AuthLDAPBindPassword xxxxxxxx Require valid-user </Location> <Location /person> DAV svn SVNListParentPath on SVNParentPath /opt/svn/person AuthType Basic AuthName "Subversion Authentication Person" AuthBasicProvider ldap AuthzLDAPAuthoritative off AuthLDAPURL ldap://192.168.77.125:389/ou=person,dc=kuitan,dc=net?sAMAccountName?sub?(objectClass=*) AuthLDAPBindDN Administrator@kuitan.net AuthLDAPBindPassword xxxxxxxx Require valid-user </Location> [root@web03 ~]# /etc/init.d/httpd restart
※表示の都合上タグを"<"と">"で記載。
※<Location /users>の設定ではcn=usersに属するユーザがアクセスできるリポジトリを定義している。
※<Location /person>の設定ではou=personに属するユーザがアクセスできるリポジトリを定義している。

■ブラウザからアクセス
https://192.168.77.147/users/
Basic認証の画面が表示され、ADに登録したユーザ(cn=usersに属するユーザ)でアクセスする。



その後、https://192.168.77.147/person/にアクセスすると再びBasic認証を要求される。
ou=personに属するユーザでアクセスする。


※ちなみに、上記を行うだけならWebサーバ側にopenldap-clientsパッケージは不要。

2013年3月8日金曜日

Windows Server 2008 R2 の Active Directory を ldapsearchで検索


Windows Server 2008 R2 の Active Directory 上のユーザをLinuxのldapsearchコマンドを利用して検索できるか確認します。
LinuxサーバのSubversionの認証にADを利用するための事前検証という位置付けです。

【ADサーバ】
OS: Windows Server 2008 R2(64-bit)
Domain Name: kuitan.net
IP: 192.168.77.125

【Linuxサーバ】
OS: CentOS 6.3(64-bit)
openldap-clients: 2.4.23
IP: 192.168.77.147


■Active Directoryにユーザ作成

↑標準的な場所にaduser01~05を作成。

↑組織単位(OU)として「person」を作成し、ObjectClassにInetOrgPersonを指定したユーザpuser01~02を作成。

■openldap-clientsインストール
※ldapsearchコマンドを利用するにはopenldap-clientsパッケージが必要。
[root@cent63 ~]# yum install openldap-clients ====================================================================== Package Arch Version Repository Size ====================================================================== Installing: openldap-clients x86_64 2.4.23-26.el6_3.2 updates 164 k Updating for dependencies: openldap x86_64 2.4.23-26.el6_3.2 updates 262 k Transaction Summary ====================================================================== Install 1 Package(s) Upgrade 1 Package(s) (以下省略)

■ldapsearchコマンドで接続確認
[root@cent63 ~]# ldapsearch -x -D "cn=administrator,dc=kuitan,dc=net" -w xxxxxxxx -h 192.168.77.125 -b "cn=users,dc=kuitan,dc=net" "(objectclass=*)" "sAMAccountName=username" ldap_bind: Invalid credentials (49) additional info: 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db0 [root@cent63 ~]#
→接続失敗。
Invalid credentials (49) は、ユーザIDやパスワードが間違っているとよく出るエラー。らしい。

今回はDNの指定が間違っていたので修正して再検索
[root@cent63 ~]# ldapsearch -x -D "cn=administrator,cn=users,dc=kuitan,dc=net" -w xxxxxxxx -h 192.168.77.125 -b "cn=users,dc=kuitan,dc=net" "(objectclass=*)" "sAMAccountName=username" (中略) # aduser04, Users, kuitan.net dn: CN=aduser04,CN=Users,DC=kuitan,DC=net # aduser05, Users, kuitan.net dn: CN=aduser05,CN=Users,DC=kuitan,DC=net # Administrator, Users, kuitan.net dn: CN=Administrator,CN=Users,DC=kuitan,DC=net # Guest, Users, kuitan.net dn: CN=Guest,CN=Users,DC=kuitan,DC=net # search result search: 2 result: 0 Success # numResponses: 26 # numEntries: 25 [root@cent63 ~]#

DNの指定は、「ユーザ@ドメイン」としてもよい。
※OU=personの下のユーザを検索。
[root@cent63 ~]# ldapsearch -x -D "administrator@kuitan.net" -w xxxxxxxx -h 192.168.77.125 -b "ou=person,dc=kuitan,dc=net" "(objectclass=*)" "sAMAccountName=username" # extended LDIF # # LDAPv3 # base with scope subtree # filter: (objectclass=*) # requesting: sAMAccountName=username # # person, kuitan.net dn: OU=person,DC=kuitan,DC=net # puser01, person, kuitan.net dn: CN=puser01,OU=person,DC=kuitan,DC=net # puser02, person, kuitan.net dn: CN=puser02,OU=person,DC=kuitan,DC=net # search result search: 2 result: 0 Success # numResponses: 4 # numEntries: 3 [root@cent63 ~]#
※ちなみに、ldapsearchで検索するためにcent63サーバをADのドメインに参加させる必要はありません。

2012年2月12日日曜日

ApacheからKerberos認証でADユーザを利用する

Apacheにmod_auth_kerbを組み込み、Kerberos認証を使ってActiveDirectoryのユーザを利用する方法です。 Basic認証より安全かも。AD一元管理されたユーザ/パスワードを利用できるので運用がラク。
・ActiveDirectoryサーバOS: Windows Server 2008 R2
 → FQDNは win2k8r2-ad01.kuitan.net

・LinuxサーバOS: CentOS6.2 (64-bit)
 →Apacheバージョン: 2.2.15
 →Sambaバージョン: 3.5.10
 ※その他、samba-winbindが必要です。事前準備ヨロ。


--- Step1. まずはActiveDirectoryサーバに接続させる。 ---

■smb.confの設定 ⇒[global]セクションの最下部に下記を追記 [root@srv04 samba]# vi smb.conf 262行目あたりから # ---- Settings for Winbind ---- security = ads workgroup = KUITAN realm = KUITAN.NET password server = win2k8r2-ad01.kuitan.net encrypt passwords = true idmap uid = 10000-25000 idmap gid = 10000-20000 winbind use default domain = yes winbind cache time = 90 # winbind nested groups = yes # template shell = /bin/bash # template homedir = /home/%U ■nsswitch.confの設定 [root@srv04 ~]# vi /etc/nsswitch.conf [root@srv04 ~]# grep -n winbind /etc/nsswitch.conf 33:passwd: files winbind 34:shadow: files winbind 35:group: files winbind ■AD連携に必要なSamba関連パッケージ確認 [root@srv04 ~]# rpm -qa | grep samba samba-winbind-clients-3.5.10-114.el6.x86_64 samba4-libs-4.0.0-23.alpha11.el6.x86_64 samba-common-3.5.10-114.el6.x86_64 samba-client-3.5.10-114.el6.x86_64 samba-3.5.10-114.el6.x86_64 [root@srv04 ~]# ・samba →OK ・samba-client →OK ・samba-common →OK ・samba-winbind →ないので追加インストール ⇒yumレポジトリの設定 [root@srv04 ~]# vi /etc/yum.repos.d/dvd.repo [root@srv04 ~]# cat /etc/yum.repos.d/dvd.repo [dvd] name=CentOS-6.2-x86_64-DVD1 baseurl=file:///media/CentOS_6.2_Final/ enabled=0 gpgcheck=1 gpgkey=file:///media/CentOS_6.2_Final/RPM-GPG-KEY-CentOS-6 [root@srv04 ~]# ⇒samba-winbindをメディアからインストール [root@srv04 ~]# yum --disablerepo=\* --enablerepo=dvd install samba-winbind (中略) Installed: samba-winbind.x86_64 0:3.5.10-114.el6 Complete! [root@srv04 ~]# ■krb5.confの設定 [root@srv04 ~]# vi /etc/krb5.conf [root@srv04 ~]# cat /etc/krb5.conf [logging] default = FILE:/var/log/krb5libs.log kdc = FILE:/var/log/krb5kdc.log admin_server = FILE:/var/log/kadmind.log [libdefaults] default_realm = KUITAN.NET dns_lookup_realm = false dns_lookup_kdc = false ticket_lifetime = 24h renew_lifetime = 7d forwardable = true [realms] KUITAN.NET = { kdc = win2k8r2-ad01.kuitan.net admin_server = win2k8r2-ad01.kuitan.net } [domain_realm] .kuitan.net = KUITAN.NET kuitan.net = KUITAN.NET [root@srv04 ~]# ■/etc/hosts修正 [root@srv04 ~]# cat /etc/hosts 127.0.0.1 srv04.kuitan.net srv04 localhost localhost.localdomain localhost4 localhost4.localdomain4 # ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.xxx.144 srv04.kuitan.net srv04 192.168.xxx.125 win2k8r2-ad01.kuitan.net [root@srv04 ~]# ■samba起動 [root@srv04 ~]# /etc/init.d/smb start SMB サービスを起動中: [ OK ] [root@srv04 ~]# ■ADサーバと時刻同期 [root@srv04 ~]# net time set -I win2k8r2-ad01.kuitan.net 2012年 2月 12日 日曜日 15:43:10 JST [root@srv04 ~]# net ads info LDAP server: 192.168.xxx.125 LDAP server name: win2k8r2-ad01.kuitan.net Realm: KUITAN.NET Bind Path: dc=KUITAN,dc=NET LDAP port: 389 Server time: 日, 12 2月 2012 15:43:14 JST KDC server: 192.168.xxx.125 Server time offset: 0 [root@srv04 ~]# /etc/init.d/winbind status winbindd は停止しています [root@srv04 ~]# →winbindが停止していてもドメインへの接続は可能。 ■winbindを起動してAD上のユーザを確認 [root@srv04 ~]# wbinfo -u Error looking up domain users [root@srv04 ~]# /etc/init.d/winbind start Winbind サービスを起動中: [ OK ] [root@srv04 ~]# wbinfo -u administrator guest krbtgt aduser01 aduser02 aduser03 aduser04 aduser05 [root@srv04 ~]#

--- Step2. ApacheからKerberos認証を利用する設定 ---

■mod_auth_kerbインストール [root@srv04 ~]# yum --disablerepo=\* --enablerepo=dvd install mod_auth_kerb (中略) Installed: mod_auth_kerb.x86_64 0:5.4-6.el6 Complete! [root@srv04 ~]# ■keytabファイル作成 [root@srv04 ~]# net ads keytab add HTTP -U administrator Warning: "kerberos method" must be set to a keytab method to use keytab functions. Processing principals to add... Enter administrator's password: [root@srv04 ~]# ⇒確認 [root@srv04 ~]# ll /etc/krb5.keytab -rw------- 1 root root 363 2月 12 15:56 2012 /etc/krb5.keytab [root@srv04 ~]# net ads keytab list Warning: "kerberos method" must be set to a keytab method to use keytab functions. Vno Type Principal 3 DES cbc mode with CRC-32 HTTP/srv04.kuitan.net@KUITAN.NET 3 DES cbc mode with RSA-MD5 HTTP/srv04.kuitan.net@KUITAN.NET 3 ArcFour with HMAC/md5 HTTP/srv04.kuitan.net@KUITAN.NET 3 DES cbc mode with CRC-32 HTTP/srv04@KUITAN.NET 3 DES cbc mode with RSA-MD5 HTTP/srv04@KUITAN.NET 3 ArcFour with HMAC/md5 HTTP/srv04@KUITAN.NET [root@srv04 ~]# ■確認用コンテンツ準備 [root@srv04 ~]# mkdir /var/www/html/krb [root@srv04 ~]# vi /var/www/html/krb/index.html [root@srv04 ~]# cat /var/www/html/krb/index.html <html lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> Kerberos認証に成功しました。<br> </body> </html> [root@srv04 ~]# ■auth_kerb.conf [root@srv04 ~]# cd /etc/httpd/conf.d/ [root@srv04 conf.d]# cp -p auth_kerb.conf auth_kerb.conf.20040909 [root@srv04 conf.d]# vi auth_kerb.conf [root@srv04 conf.d]# grep -v "^#\|^$" auth_kerb.conf LoadModule auth_kerb_module modules/mod_auth_kerb.so AuthType Kerberos AuthName "Kerberos Login" KrbMethodNegotiate Off KrbMethodK5Passwd On KrbAuthRealms KUITAN.NET Krb5KeyTab /etc/krb5.keytab KrbVerifyKDC Off require valid-user [root@srv04 conf.d]# ■Apache起動 [root@srv04 ~]# /etc/init.d/httpd start httpd を起動中: [ OK ] [root@srv04 ~]# ■ブラウザから接続確認
http://192.168.xxx.144/krb/ ユーザ:aduser01 パスワード:******* 画面に「Kerberos認証に成功しました。」と表示されれば成功です。 ■その他補足1 ⇒httpd-develとkrb5-develは不要だった [root@srv04 ~]# rpm -qa | grep httpd httpd-tools-2.2.15-15.el6.centos.x86_64 httpd-2.2.15-15.el6.centos.x86_64 httpd-manual-2.2.15-15.el6.centos.noarch [root@srv04 ~]# rpm -qa | grep krb5 krb5-libs-1.9-22.el6.x86_64 krb5-workstation-1.9-22.el6.x86_64 pam_krb5-2.3.11-9.el6.x86_64 [root@srv04 ~]# →インストールしていなくても動作した。 ■その他補足2 auth_kerb.confのKrbMethodNegotiate の値をOffにすると、 Kerberosではなさそうな認証画面が表示され、正しいユーザと パスワードを入力してもInternal Server Errorとなった。 [root@srv04 conf.d]# grep -v "^#\|^$" auth_kerb.conf LoadModule auth_kerb_module modules/mod_auth_kerb.so AuthType Kerberos AuthName "Kerberos Login" KrbMethodNegotiate On ←Offから変更 KrbMethodK5Passwd On KrbAuthRealms KUITAN.NET Krb5KeyTab /etc/krb5.keytab KrbVerifyKDC Off require valid-user [root@srv04 conf.d]# [root@srv04 ~]# /etc/init.d/httpd restart httpd を停止中: [ OK ] httpd を起動中: [ OK ] [root@srv04 ~]#
→OKボタンを押してもInternal Server Errorになった…。

2012年2月1日水曜日

ApacheからNTML認証でADユーザを利用する


Apacheにmod_auth_ntlm_winbindを組み込み、NTML認証を使ってActiveDirectoryのユーザを利用する方法です。 Basic認証より安全かも。AD一元管理されたユーザ/パスワードを利用できるので運用がラク。
・ActiveDirectoryサーバOS: Windows Server 2008 R2
 → FQDNは win2k8r2-ad01.kuitan.net

・LinuxサーバOS: CentOS6.2 (64-bit)
 →Apacheバージョン: 2.2.15
 →Sambaバージョン: 3.5.10
 ※その他、samba-winbind、httpd-develが必要です。事前準備ヨロ。


■mod_auth_ntlm_winbindの取得
[root@centos62 ダウンロード]# svn co svn://svnanon.samba.org/lorikeet/trunk/mod_auth_ntlm_winbind mod_auth_ntlm_winbind
A    mod_auth_ntlm_winbind/contrib
A    mod_auth_ntlm_winbind/contrib/mod_auth_ntlm_winbind-20060510-connect_http10.patch
A    mod_auth_ntlm_winbind/Makefile.in
A    mod_auth_ntlm_winbind/debian
A    mod_auth_ntlm_winbind/debian/control
A    mod_auth_ntlm_winbind/debian/auth_ntlm_winbind.load
A    mod_auth_ntlm_winbind/debian/compat
A    mod_auth_ntlm_winbind/debian/changelog
A    mod_auth_ntlm_winbind/debian/copyright
A    mod_auth_ntlm_winbind/debian/rules
A    mod_auth_ntlm_winbind/500mod_auth_ntlm_winbind.info
A    mod_auth_ntlm_winbind/AUTHORS
A    mod_auth_ntlm_winbind/VERSION
A    mod_auth_ntlm_winbind/mod_auth_ntlm_winbind.c
A    mod_auth_ntlm_winbind/configure.in
A    mod_auth_ntlm_winbind/README
 U   mod_auth_ntlm_winbind
リビジョン 801 をチェックアウトしました。
[root@centos62 ダウンロード]#


■mod_auth_ntlm_winbindのインストール(1分以内で完了)
[root@centos62 ダウンロード]# cd mod_auth_ntlm_winbind/
[root@centos62 mod_auth_ntlm_winbind]# autoconf
[root@centos62 mod_auth_ntlm_winbind]# ./configure --with-apxs=/usr/sbin/apxs --with-apache=/usr/sbin/httpd
checking for gcc... gcc
checking for C compiler default output file name... a.out
(後略)

[root@centos62 mod_auth_ntlm_winbind]# make
/usr/sbin/apxs -DAPACHE2 -Wc,-Wall -c mod_auth_ntlm_winbind.c
/usr/lib64/apr-1/build/libtool --silent --mode=compile gcc -prefer-pic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wformat-security -fno-strict-aliasing  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/httpd  -I/usr/include/apr-1   -I/usr/include/apr-1  -Wall -DAPACHE2  -c -o mod_auth_ntlm_winbind.lo mod_auth_ntlm_winbind.c && touch mod_auth_ntlm_winbind.slo
/usr/lib64/apr-1/build/libtool --silent --mode=link gcc -o mod_auth_ntlm_winbind.la  -rpath /usr/lib64/httpd/modules -module -avoid-version    mod_auth_ntlm_winbind.lo
[root@centos62 mod_auth_ntlm_winbind]#

[root@centos62 mod_auth_ntlm_winbind]# make install
/usr/sbin/apxs -DAPACHE2 -S LIBEXECDIR=//usr/lib64/httpd/modules -n auth_ntlm_winbind -i .libs/mod_auth_ntlm_winbind.so
/usr/lib64/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool' .libs/mod_auth_ntlm_winbind.so //usr/lib64/httpd/modules
/usr/lib64/apr-1/build/libtool --mode=install cp .libs/mod_auth_ntlm_winbind.so //usr/lib64/httpd/modules/
libtool: install: cp .libs/mod_auth_ntlm_winbind.so //usr/lib64/httpd/modules/mod_auth_ntlm_winbind.so
Warning!  dlname not found in //usr/lib64/httpd/modules/mod_auth_ntlm_winbind.so.
Assuming installing a .so rather than a libtool archive.
chmod 755 //usr/lib64/httpd/modules/mod_auth_ntlm_winbind.so
[root@centos62 mod_auth_ntlm_winbind]#
■表示確認用コンテンツ準備
[root@centos62 ~]# mkdir /var/www/html/ntlm
[root@centos62 ~]# vi /var/www/html/ntlm/index.html
[root@centos62 ~]# cat /var/www/html/ntlm/index.html
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#99ffdd">
NTLM認証に成功しました。<br />
</body>
</html>
[root@centos62 ~]#


■httpd.confの設定
[root@centos62 ~]# cd /etc/httpd/conf/
[root@centos62 conf]# cp -p httpd.conf httpd.conf.20100528
[root@centos62 ~]# vi /etc/httpd/conf/httpd.conf
------------------------------------------------
76行目あたり(Off→On)
KeepAlive On

202行目あたり(追記)
LoadModule auth_ntlm_winbind_module modules/mod_auth_ntlm_winbind.so

最下行に追記
# for NTLM settings
Alias /ntlm/ "/var/www/html/ntlm/"
<Directory "/var/www/html/ntlm/">
  NTLMAuth on
  AuthType NTLM
  AuthName "NTLM Authentication"
  NTLMAuthHelper "/usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp"
  NTLMBasicAuthoritative on
  require valid-user
</Directory>
------------------------------------------------


■winbindd_privilegedディレクトリにApache(mod_auth_ntlm_winbind)のプロセスのユーザへのアクセス権を設定
[root@centos62 ~]# chgrp apache /var/lib/samba/winbindd_privileged


■Apacheを起動
[root@centos62 ~]# /etc/init.d/httpd start
httpd を起動中:                                            [  OK  ]


■ブラウザからアクセス
http://192.168.xxx.143/ntlm/
NTLM認証に成功しました。の画面が表示されれば成功!!

※ちなみに、smb.conf等の設定が間違っていたりするとあっさり401がお目見えします。

Authorization Required

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.


Apache/2.2.15 (CentOS) Server at 192.168.xxx.143 Port 80

2012年1月29日日曜日

LinuxサーバをActiveDirectoryに連携させる


ActiveDirectory上で一元管理されたユーザをLinuxサーバ上で使うことが目的です。
・ActiveDirectoryサーバOS: Windows Server 2008 R2
 → FQDNは win2k8r2-ad01.kuitan.net
・LinuxサーバOS: CentOS6.2 (64-bit)


■/etc/hostsに自HOSTおよびADサーバを追加

[root@centos62 ~]# vi /etc/hosts
[root@centos62 ~]# cat /etc/hosts
# 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1   centos62 localhost localhost.localdomain
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.xxx.125   win2k8r2-ad01.kuitan.net win2k8r2-ad01
[root@centos62 ~]#

■resolv.confの設定

[root@centos62 ~]# vi /etc/resolv.conf
[root@centos62 ~]# cat /etc/resolv.conf
# Generated by NetworkManager


# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com

search kuitan.net
nameserver 192.168.xxx.125
[root@centos62 ~]#

⇒networkサービスを再起動すると設定がクリアされてしまうのでifcfg-eth0に記述
[root@centos62 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
[root@centos62 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=00:0C:29:xx:xx:xx
TYPE=Ethernet
BOOTPROTO=none
IPADDR=192.168.xxx.143
PREFIX=24
GATEWAY=192.168.xxx.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5xxx6bd0-0ba0-7ffb-4xx1-d6xxxxxf3203
DOMAIN=kuitan.net
DNS1=192.168.xxx.125
[root@centos62 ~]#

[root@centos62 ~]# /etc/init.d/network restart
インターフェース eth0 を終了中:  デバイスの状態: 3 (切断済み)
                                                           [  OK  ]
ループバックインターフェースを終了中                       [  OK  ]
ループバックインターフェイスを呼び込み中                   [  OK  ]
インターフェース eth0 を活性化中:  アクティブ接続の状態: アクティベート済み
アクティブ接続のパス: /org/freedesktop/NetworkManager/ActiveConnection/3
                                                           [  OK  ]
[root@centos62 ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search kuitan.net
nameserver 192.168.xxx.125
[root@centos62 ~]#

■Windbindに必要なSambaのパッケージ確認(samba-clientとsamba-commonが必要)

[root@centos62 ~]# rpm -qa | grep samba
samba-winbind-clients-3.5.10-114.el6.x86_64
samba-3.5.10-114.el6.x86_64
samba4-libs-4.0.0-23.alpha11.el6.x86_64
samba-common-3.5.10-114.el6.x86_64
samba-client-3.5.10-114.el6.x86_64
[root@centos62 ~]#

■Winbindがない場合はあらかじめインストールしておく(CentOS6.2インストールメディアより)

[root@centos62 ~]# rpm -ivh /media/CentOS_6.2_Final/Packages/samba-winbind-3.5.10-114.el6.x86_64.rpm
警告: /media/CentOS_6.2_Final/Packages/samba-winbind-3.5.10-114.el6.x86_64.rpm: ヘッダ V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
準備中...                ################################# [100%]
   1:samba-winbind          ################################# [100%]
[root@centos62 ~]# rpm -qa | grep winbind
samba-winbind-clients-3.5.10-114.el6.x86_64
samba-winbind-3.5.10-114.el6.x86_64
[root@centos62 ~]#
※ntlm_authコマンドも利用できるようになる。

■smb.confの設定([global]セクションに下記を追加)

[root@centos62 ~]# cd /etc/samba
[root@centos62 samba]# ll
合計 20
-rw-r--r--. 1 root root   20 12月  8 09:15 2011 lmhosts
-rw-r--r--. 1 root root 9778 12月  8 09:15 2011 smb.conf
-rw-r--r--. 1 root root   97 12月  8 09:15 2011 smbusers
[root@centos62 samba]# cp -p smb.conf smb.conf.20111208
[root@centos62 samba]# vi smb.conf

245行目あたりから
# ---- Settings for Winbind ----
  security = ads
  workgroup = KUITAN
  realm = KUITAN.NET
  password server = win2k8r2-ad01.kuitan.net
  encrypt passwords = true
  idmap uid = 10000-25000
  idmap gid = 10000-20000
  winbind use default domain = yes
  winbind cache time = 90
#  winbind nested groups = yes
#  template shell = /bin/bash
#  template homedir = /home/%U

■nsswitch.confの設定

[root@rails01 ~]# cp -p /etc/nsswitch.conf /etc/nsswitch.conf.20040923
[root@rails01 ~]# vi /etc/nsswitch.conf
33行目あたりを修正
passwd:     files winbind
shadow:     files winbind
group:      files winbind

■krb5.confの設定

[root@centos62 ~]# cp -p /etc/krb5.conf /etc/krb5.conf.20100218
[root@centos62 ~]# vi /etc/krb5.conf
[root@centos62 ~]# cat /etc/krb5.conf
[logging]
 default = FILE:/var/log/krb5libs.log
 kdc = FILE:/var/log/krb5kdc.log
 admin_server = FILE:/var/log/kadmind.log

[libdefaults]
 default_realm = KUITAN.NET
 dns_lookup_realm = false
 dns_lookup_kdc = false
 ticket_lifetime = 24h
 renew_lifetime = 7d
 forwardable = true

[realms]
 KUITAN.NET = {
  kdc = win2k8r2-ad01.kuitan.net
  admin_server = win2k8r2-ad01.kuitan.net
 }

[domain_realm]
 .kuitan.net = KUITAN.NET
 kuitan.net = KUITAN.NET
[root@centos62 ~]#

⇒下記のようにviの文字列置換を使うとラク。
:%s/EXAMPLE.COM/KUITAN.NET/g
:%s/kerberos.example.com/win2k8r2-ad01.kuitan.net/g
:%s/example.com/kuitan.net/g

■smbとwinbindを起動

[root@centos62 ~]# /etc/init.d/smb start
SMB サービスを起動中:                                      [  OK  ]
[root@centos62 ~]# /etc/init.d/winbind start
Winbind サービスを起動中:                                  [  OK  ]
[root@centos62 ~]#

■Windowsドメインに参加

[root@centos62 ~]# net ads join -U administrator
Enter administrator's password:
Using short domain name -- KUITAN
Joined 'CENTOS62' to realm 'kuitan.net'
[2012/01/29 01:52:23.073504,  0] libads/kerberos.c:333(ads_kinit_password)
  kerberos_kinit_password CENTOS62$@KUITAN.NET failed: Clock skew too great
No DNS domain configured for centos62. Unable to perform DNS Update.
DNS update failed!
[root@centos62 ~]#
⇒時刻のずれが大きいため接続できない。

⇒ADサーバと時刻同期
[root@centos62 ~]# net time set -I win2k8r2-ad01.kuitan.net
2012年  1月  29日 日曜日 01:42:17 JST
[root@centos62 ~]#

⇒時刻同期後再実行
[root@centos62 ~]# net ads join -U administrator
Enter administrator's password:
Using short domain name -- KUITAN
Joined 'CENTOS62' to realm 'kuitan.net'
No DNS domain configured for centos62. Unable to perform DNS Update.
DNS update failed!
[root@centos62 ~]#

⇒接続確認
[root@centos62 ~]# net ads info
LDAP server: 192.168.xxx.125
LDAP server name: win2k8r2-ad01.kuitan.net
Realm: KUITAN.NET
Bind Path: dc=KUITAN,dc=NET
LDAP port: 389
Server time: 日, 29  1月 2012 01:45:45 JST
KDC server: 192.168.xxx.125
Server time offset: 1
[root@centos62 ~]# net ads testjoin
Join is OK

⇒AD上のユーザとグループの表示
[root@centos62 ~]# wbinfo -u
administrator
guest
krbtgt
aduser01
aduser02
[root@centos62 ~]# wbinfo -g
domain computers
domain controllers
schema admins
enterprise admins
cert publishers
domain admins
domain users
domain guests
group policy creator owners
ras and ias servers
allowed rodc password replication group
denied rodc password replication group
read-only domain controllers
enterprise read-only domain controllers
dnsadmins
dnsupdateproxy
[root@centos62 ~]#

[root@centos62 ~]# id aduser01
uid=10000(aduser01) gid=10000(domain users) 所属グループ=10000(domain users)

[root@centos62 ~]# ntlm_auth --username=KUITAN\\aduser02
password:
NT_STATUS_OK: Success (0x0)
[root@centos62 ~]#

この情報が何かのお役にたてれば幸いです。スポソサ~へのご協力いただけると幸いです。m(_ _)m

2012年1月22日日曜日

Windows Server 2008 R2 パスワードポリシーの変更

Windows Server 2008 R2 でADユーザを作成しようとした際、「パスワードは、複雑さの要件を満たす必要がある」と警告が表示され苛立ちを覚えた時の対処法です。


■パスワードポリシーの変更
スタート → 管理ツール → ローカル セキュリティー ポリシー
セキュリティの設定/アカウント ポリシー/パスワードのポリシー
ラジオボタンがグレーアウトされており、変更できない!!

⇒DCに昇格した場合は、グループポリシーの管理から設定する。
スタート → 管理ツール → グループ ポリシーの管理

Default Domain Policy を右クリックして編集を選択
コンピュータの構成/ポリシー/Windows の設定/セキュリティの設定/アカウント ポリシー/パスワードのポリシー
「グループポリシーの管理」画面を閉じた時にその設定が反映される。

この情報がお役に立ちましたら、いえ、ご寄付はいりません。サイト継続にご協力いただければ…。 m(_ _)m

2012年1月21日土曜日

Windows Server 2008 R2 Active Directory インストール

Windows Server 2008 R2 に Active Directoryを設定する手順をまとめてみました。
主な設定項目は下記。
・OSバージョン: Windows Server 2008 R2 Standard
・ドメインの機能レベル: Windows Server 2008
・フォレストの機能レベル: Windows Server 2008
・コンピュータ名: win2k8r2-ad01
・DNSドメイン名(Active Directoryドメイン名): kuitan.net
・NetBIOSドメイン名: KUITAN
・DNSサーバ・アドレス: 127.0.0.1(ローカル・ループバック・アドレス)


■コンピュータ名とNetBIOSドメイン名の設定
コントロール パネル → システムとセキュリティ → システム → システムの詳細設定 →
コンピュータ名タブ → 変更ボタン

■IPアドレスとDNSサーバ設定の変更
コントロール パネル → ネットワークとインターネット → ネットワーク接続 →
Local Area Connectionのプロパティ → インターネット プロトコル バージョン 4 (TCP/IPv4)のプロパティ
DNSサーバのアドレスに自分自身を指すように設定する。

■Active Directoryウィザードによるインストール
スタートメニュー → ファイル名を指定して実行 → 「dcpromo」と入力
後は画面キャプチャ参照
(※補足)DNSサーバが見つからないので、上記のようなメッセージが表示されているが、[はい]を選択して先へ進めて問題なし。
-- 概要 --
新しいフォレストの最初の Active Directory ドメイン コントローラーとしてこのサーバーを構成します。
新しいドメイン名は "kuitan.net" です。これは新しいフォレスト名にもなります。
ドメインの NetBIOS 名は "KUITAN" です。
フォレストの機能レベル: Windows Server 2008 R2
ドメインの機能レベル: Windows Server 2008 R2
サイト: Default-First-Site-Name
追加オプション:
  読み取り専用ドメイン コントローラー: "いいえ"
  グローバル カタログ: はい
  DNS サーバー: はい
DNS 委任の作成: いいえ
データベースの場所: C:\Windows\NTDS
ログ ファイルの場所: C:\Windows\NTDS
SYSVOL フォルダーの場所: C:\Windows\SYSVOL
DNS サーバー サービスはこのコンピューターにインストールされます。
DNS サーバー サービスはこのコンピューターに構成されます。
このコンピューターは、この DNS サーバーを優先 DNS サーバーとして使用するように構成されます。
新しいドメイン Administrator アカウントのパスワードはこのコンピューターのローカル Administrator アカウントのパスワードと同じものに設定されます。
これにてActive Directoryのインストールは無事完了。
以後、ドメイン・コントローラには、ローカル・ユーザー・アカウントはないので下記のようにドメイン名\アカウントで接続する。

サーバーマネージャーでActive Directory のデフォルトユーザ等を確認すると下記のようになっています。